- Clone and run your project
sudo apt updatesudo apt install python3-pip python3-dev nginxsudo pip3 install virtualenvpython3 -m venv envsource ./env/bin/activatepip install gunicorndeactivatesudo vim /etc/systemd/system/gunicorn.socket
Paste the content below
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.targetsudo vim /etc/systemd/system/gunicorn.service
Paste the content below
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=<username>
Group=www-data
WorkingDirectory=/home/<username>/<projectdir>
ExecStart=/home/<username>/<projectdir>/env/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
<application_name>.wsgi:application
[Install]
WantedBy=multi-user.target-
sudo systemctl start gunicorn.socket -
sudo systemctl enable gunicorn.socket -
sudo vim /etc/nginx/sites-available/<application_name>
Paste the content below
server {
server_name www.domain_name.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/<username>/<projectdir>;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}sudo ln -s /etc/nginx/sites-available/<application_name> /etc/nginx/sites-enabled/sudo systemctl restart nginx
sudo apt install python3-certbot-nginx certbotsudo certbot --nginx
sudo vim /etc/nginx/site-available/<application-name>- Paste the following in the nginx config file
server {
server_name estate.nitdgplug.org;
location / {
root /home/tux/estate_permissions_portal_frontend/build;
try_files $uri /index.html;
}
}sudo ln -s /etc/nginx/sites-available/<application_name> /etc/nginx/sites-enabled/sudo systemctl restart nginx