Django Boys Tutorial from DjangoGirls
- Create server via AWS EC2 or Digital Ocean Droplet, or other similar service
-
Prepare server with this setup: https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-22-04
-
Allow ubuntu user to have sudo privileges
- logged in via ssh
- type
sudo visudo
- add
username ALL=(ALL) NOPASSWD: ALL
to the file - save and exit
-
Create ssh keys for server add add to git so server can download repo
-
Download repo
-
Create
.env
file from.env.sample
: cp.env.sample
.env
-
Follow tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-22-04
-
Check for static files access
sudo -u www-data stat /home/ubuntu/djangoboys/static
It it gives the error:
stat: cannot statx '/home/ubuntu/djangoboys/static': Permission denied
Then
Add the www-data to the username group:
sudo gpasswd -a www-data username
- If nginx gives this error:
nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 64
nginx: configuration file /etc/nginx/nginx.conf test failed
Then
Edit the nginx.conf and on the http block, add this line:
http{ server_names_hash_bucket_size 64; ... }
-
Also check this tutorial in case of errors: https://pylessons.com/django-deployment
-
Visit your site and verify deployment