Adserver Live Version Code
Brought to you by:
usamacs
######################################################################################################### This is a readme file ######################################################################################################### Please Follow the below instructions to run Humkinar Adserver Service on your System ######################################################################################################### Software Requirements ######################################################################################################### 1. Pycharm (Ubuntu Software Center) 2. Python 3.6.7 (Bash Script Name ===> packagesinstaller) 3. Django 2.1.3 (Filename ===> requirements.txt) 4. Django Rest Framework 3.9.0 (Filename ===> requirements.txt) 5. LAMP Stack (Filename ===> lampstack.txt) 6. Apache Solr 6.6.1 (Link ===> http://archive.apache.org/dist/lucene/solr/) ######################################################################################################### Steps to follow before running the Humkinar searchAd Service Assuming no software and packages are already installed If any package is already installed, please move onto the next step ######################################################################################################### ######################################################################################################### - Run the package installer script. This will install the software and packages required for the Adserver ./packagesinstaller.sh Pycharm ########################### - From the Ubuntu Software Center, install "Pycharm" Python Packages ########################### - From the directory "/searchAdsDjango" run the following command in terminal: pip install -r /requirements.txt Lamp Stack ########################### - To install LAMP stack, please follow the instructions in the file "lampstack.txt" - After installing LAMP stack, open phpmyadmin from browser by typing : <ipaddress>/phpmyadmin OR localhost/phpmyadmin - Create a new database Solr ########################### - Download and build Apache Solr 6.6.1 - After you have built Solr, open the solr directory "<solr_path>/solr-6.6.1/" and run the following command to make a new core. bin/solr create -c <corename> - After making the core, go to the address : <solr_path>/solr-6.6.1/server/solr/<corename>/conf - Open the "managed-schema" file in the directory - Copy the contents of the file "managed-schema" which came with the Adserver Source Code and paste it in the "managed-schema" file of the Solr directory mentioned in the step above. Save the "managed-schema" file and close it - Now open the directory "<solr_path>/solr-6.6.1/" and run the following command to start the solr instance bin/solr start - Note: Default port at which the solr runs is 8983 - Open the browser and enter the following address to check if solr is running <ipaddress>:<portnumber> - Now solr is running on your system ######################################################################################################### ######################################################################################################### Launching the Adserver Service ######################################################################################################### - Now launch Pycharm and open the project "searchAdsDjango" in it - Open the file "settings.py" - Add the following lines to the "settings.py" file ##################################### SOLR_HOST = <ipaddress> (Ip address of your localhost or of the server you are making the host) SOLR_PORT = <solrport> (The port number on which solr instance is running) SOLR_CORE = <solrcore> (The name of the core which you created for Adserver) ALLOWED_HOSTS = ['0.0.0.0', '10.11.21.119'] (List of all ip addresses that will access the service) INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'humkinar_ads',] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'searchads', 'USER': 'root', 'PASSWORD': 'hpcnl123', 'HOST': '127.0.0.1', 'PORT': '3306' } EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_USE_TLS = True EMAIL_PORT = 587 EMAIL_HOST_USER = 'humkinar@gmail.com' EMAIL_HOST_PASSWORD = 'humkinar@hpcnl@kics@uet' ##################################### - Save "settings.py" - Open the terminal in the source code directory where "manage.py" file is located - Run the following commands python3 manage.py makemigrations python3 manage.py migrate - After running these commands the database you created in mySQL has been populated with tables from the models.py file - Now to run the Adserver service, run the command python3 manage.py runserver <ipaddress>:<portnumber> (Define any unused port of the system) OR python3 manage.py runserver 0.0.0.0:<portnumber> - Now the Adserver service is running - Make sure that your ip address is added on the firewall of the host system - If it is not added, run the following commands sudo ufw allow from <ipaddress> sudo ufw status ######################################################################################################### Search Ads ######################################################################################################### - To search some ads send a GET request from any browser or Postman with the following format http://<ipaddress>:<portnumber>/query/api/middleware?query=<keywords> - Ads will be retrived if there are some ads indexed on the solr core