|
1 | 1 | <h1 align="center"> |
2 | | -Python Search Engine 2.0 |
| 2 | +Python Search Engine 2.0 Server setup |
3 | 3 | </h1> |
4 | 4 |
|
5 | 5 | ### Create virtual environment |
6 | 6 |
|
7 | | -``` python -m venv search_engine ``` |
| 7 | +``` mkdir pysearch ``` |
| 8 | + |
| 9 | +``` cd pysearch ``` |
| 10 | + |
| 11 | +``` sudo apt install python3.9 python3.9-venv python3.9-distutils ``` |
| 12 | + |
| 13 | +``` python3.9 -m venv pysearch ``` |
8 | 14 |
|
9 | 15 | ### Activate virtual environment (from parent folder) |
10 | 16 |
|
11 | | -```Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass``` |
| 17 | +```Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass``` & |
| 18 | + |
| 19 | +``` .\search_engine\Scripts\activate ``` or |
| 20 | + |
| 21 | +``` source pysearch/bin/activate ``` |
12 | 22 |
|
13 | | -``` .\search_engine\Scripts\activate ``` |
| 23 | +### Install PyTorch ( lightweight CPU version only ) |
| 24 | + |
| 25 | +``` pip install torch --index-url https://download.pytorch.org/whl/cpu ``` |
14 | 26 |
|
15 | 27 | ### Install required libraries |
16 | 28 |
|
17 | | -``` pip install version_requirements.txt ``` |
| 29 | +``` pip install -r requirements.txt ``` |
| 30 | + |
| 31 | +### Open firewall & update inbound port 8000 in Azure |
| 32 | + |
| 33 | +``` sudo ufw enable ``` |
| 34 | + |
| 35 | +``` sudo ufw allow 8000 ``` |
| 36 | + |
| 37 | +``` sudo ufw status ``` |
| 38 | + |
| 39 | +### Run and Test |
| 40 | + |
| 41 | +``` python app.py ``` |
| 42 | + |
| 43 | +Visit http://{your_server_ip}:8000 |
| 44 | + |
| 45 | + |
| 46 | +<h2 align="center"> |
| 47 | +Adding SSL, NGINX and deployment using GUNICORNN |
| 48 | +</h1> |
| 49 | + |
| 50 | +### Deploy the site using gunicorn |
| 51 | + |
| 52 | +``` gunicorn -w 4 -b 0.0.0.0:8000 app:app ``` |
| 53 | + |
| 54 | +``` sudo nano /etc/systemd/system/pysearch.service ``` paste code of server_setup/pysearch.service |
| 55 | + |
| 56 | +``` sudo systemctl daemon-reload ``` |
| 57 | + |
| 58 | +``` sudo systemctl restart pysearch ``` |
| 59 | + |
| 60 | +``` sudo systemctl enable pysearch ``` |
| 61 | + |
| 62 | +``` sudo systemctl status pysearch ``` |
| 63 | + |
| 64 | +### Setup Domain/ Sub-Domain |
| 65 | + |
| 66 | +Add New record in Advanced DNS in domain provider |
| 67 | + |
| 68 | +``` Type = "A Record" Host= "pysearch" Value = "server public ip" TTL = "Automatic" ``` ( Sub-Domain ) |
| 69 | + |
| 70 | +``` Type = "A Record" Host= "@" Value = "server public ip" TTL = "Automatic" ``` ( Domain ) |
| 71 | + |
| 72 | +### Installing SSL certificate |
| 73 | + |
| 74 | +``` sudo apt install certbot python3-certbot-nginx ``` |
| 75 | + |
| 76 | +``` sudo certbot --nginx -d pysearch.mallickboy.com ``` |
| 77 | + |
| 78 | +``` sudo certbot certificates ``` |
| 79 | + |
| 80 | +``` sudo systemctl status certbot.timer ``` check auto renewal |
| 81 | + |
| 82 | +### Set-Up NGINX |
| 83 | + |
| 84 | +``` sudo nano /etc/nginx/sites-available/pysearch.mallickboy.com ``` (copy contents of server_setup/pysearch.mallickboy.com) |
| 85 | + |
| 86 | +``` sudo nano /etc/nginx/sites-available/default ``` (copy contents of server_setup/default) |
| 87 | + |
| 88 | +``` sudo ln -s /etc/nginx/sites-available/pysearch.mallickboy.com /etc/nginx/sites-enabled/ ``` |
| 89 | + |
| 90 | +``` sudo nginx -t ``` |
| 91 | + |
| 92 | +``` sudo systemctl reload nginx ``` |
| 93 | + |
| 94 | +``` sudo systemctl restart nginx ``` |
| 95 | + |
| 96 | +### Visit |
18 | 97 |
|
19 | | -### Select kernel for Jupiter Notebook ( ipynb ) |
| 98 | +[ https://pysearch.mallickboy.com ](https://pysearch.mallickboy.com) |
20 | 99 |
|
21 | | -From top right corner select ``` (parent_folder)/Scripts/python.exe ``` as kernel and run |
22 | 100 |
|
23 | | -For python file use ``` python file_name ``` to execute |
24 | 101 |
|
25 | 102 | <h1 align="center"> |
26 | 103 | Output View |
|
0 commit comments