Part3 : Configuring Django Static files with Nginx
The first question in your mind should be why the static files are not working. Although it was working on your system. The answer is in your local system python is serving the static files but here we are using Nginx as our server so we have to tell Nginx to which directory it will search for static files.
for that connect to the server if you have closed, and go to the Nginx config directory and edit the config to serve static files. Use the below command.
cd /etc/nginx/sites-enabled/
sudo nano django.conf
server{ listen 80; server_name ec2-52-66-252-54.ap-south-1.compute.amazonaws.com; location / { include proxy_params; proxy_pass https://unix:/home/ubuntu/smarttuts/app.sock; } location /static { autoindex on; alias /home/ubuntu/smarttuts/smarttuts/static/; } }
NOTE: I have assumed that you have collected the static files using the command -> python manage.py collectstatic . if not please do that so that all the static files will be collected to the project folder.
Now test the configuration
sudo nginx -t
Now restart nginx
sudo service nginx restart
Visit the site you will see the static files are working