python - Stylesheets and images are not served, but other static files are -
i used django runserver
command start server when developing it, , got serve static files fine , when doing this. decided wanted use gunicorn , nginx instead of runserver
command. so, edited /etc/nginx/sites-available/mysite
file this:
server { listen 80; server_name xxx.xxx.xxx.133; access_log off; location /static/ { alias /opt/myenv/pysauce/static; } location / { 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"'; } }
i changed static_url
in mysite/settings.py
same location /static/
in nginx sites-available
file. started gunicorn gunicorn mysite.wsgi:application
, , able go on site. know gunicorn can't serve static files, know nginx can.
when went on website, weird part stylesheet weren't served, custom fonts, in static directory style sheet was. able confirm entering in address bar /static/css/foundation.css
, , resulted in 404 error. however, when entered address, /static/fonts/ubuntumono-b.ttf
prompted download. why aren't stylesheets serving, other static files are?
the first thing encourage keep log file. put following lines in config file:
access_log /dir/to/your/access.log error_log /dir/to/your/error.log
next, open log see why nginx cannot access file. if see
[errno 13] permission denied
then, permission problem, use following command grant access right:
chmod -r a+x static
Comments
Post a Comment