By Bishal Bisht
I have seen others face the same issue. Some were solved with user permission, some with a problem in configuration. However, I have double-checked the configuration and user profile and can’t figure out the root of this problem.
My project folder is at the root folder and not inside the home/user directory. Its user permission and the dir structure are as follows:
drwxr-xr-x 4 bsal_dev root 4096 Jan 17 11:44 eiapp
drwxr-xr-x 3 bsal_dev root 4096 Jan 17 14:20 enginfinity
-rwxr-xr-x 1 bsal_dev root 631 Jan 16 04:56 manage.py
drwxrwxr-x 9 bsal_dev bsal_dev 4096 Jan 17 12:05 static (STATIC_ROOT)
drwxr-xr-x 8 bsal_dev root 4096 Jan 16 04:56 statics(statics contents of the app)
drwxr-xr-x 3 bsal_dev root 4096 Jan 16 04:56 templates
drwxr-xr-x 2 bsal_dev root 4096 Jan 16 04:56 templatetags
drwxr-xr-x 4 bsal_dev root 4096 Jan 16 04:57 venv
My settings.py configuration:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, 'static')'
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'statics'),
]
MY NGINX CONFIG
/etc/nginx/sites-available/enginfinity
server {
server_name xxx.xxx.xx;
access_log off;
location /static/ {
alias /enginfinity/static
}
location / {
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
Currently, your static files are owned by your bsal_dev, so I think that Nginx might not have the privileges to access those files.
Check what user is your Nginx service running as:
ps aux | grep -i nginx
Then get that user and set the group of the static folder to the Nginx user
chown -R bsal_dev:nginx_user /path/to/your/static_folder
If this still does not work, I would recommend checking your Nginx error log:
tail -100 /var/log/nginx/error.log
Let me know how it goes! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.