-
Create a droplet
-
create a ssh key
-
copy the .pub and paste it
-
ssh into the project with the ip server address provided (ssh root@ip_serve)
-
after logging in create a user with root priveleges
- usermod -aG sudo username
-
sudo apt update
-
sudo apt install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx curl
-
log into postgresql
- sudo -u postgres psql
- CREATE DATABASE myproject;
- CREATE USER myprojectuser WITH PASSWORD 'password';
- ALTER ROLE myprojectuser SET client_encoding TO 'utf8';
- ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';
- ALTER ROLE myprojectuser SET timezone TO 'UTC';
-
create your virtual environment and django project
-
sudo ufw allow 8000
-
gunicorn --bind 0.0.0.0:8000 mysite.wsgi
-
gunicorn --bind 0.0.0.0:8000 mysite.wsgi
-
deactivate
-
sudo nano /etc/systemd/system/gunicorn.socket
- [Unit] Description=gunicorn socket
[Socket] ListenStream=/run/gunicorn.sock
[Install] WantedBy=sockets.target
-
sudo nano /etc/systemd/system/gunicorn.service * [Unit] Description=gunicorn daemon Requires=gunicorn.socket After=network.target [Service] User=sammy Group=www-data WorkingDirectory=/home/goodness/project/src ExecStart=/home/goodness/project/myprojectenv/bin/gunicorn
--access-logfile -
--workers 3
--bind unix:/run/gunicorn.sock
mysite.wsgi:application -
sudo systemctl start gunicorn.socket
-
sudo systemctl enable gunicorn.socket
-
sudo systemctl status gunicorn.socket
-
file /run/gunicorn.sock
-
sudo journalctl -u gunicorn.socket
-
sudo systemctl status gunicorn
-
sudo systemctl status gunicorn
-
sudo systemctl daemon-reload
-
sudo systemctl restart gunicorn
- [Unit] Description=gunicorn daemon Requires=gunicorn.socket After=network.target
[Service]
User=goodness
Group=www-data
WorkingDirectory=/home/goodness/Gorealla/src
ExecStart=/home/goodness/Gorealla/bin/gunicorn
--access-logfile -
--workers 3
--bind unix:/run/gunicorn.sock
mysite.wsgi:application
[Install] WantedBy=multi-user.target