I have a Django project and try to deploy it with nginx and uwsgi (since one week nowadays). I can access to the server but it doesn't show pictures and css. nginx serves static files (for example localhost:8000/static/images/image.png works) but on localhost:8001/ nothing (this page should display an image.png).
Here's my nginx.conf
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
#server unix:///home/serveur/www/gems/GEMS/gems.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name 192.168.0.119; # substitute your machine's IP address or FQ
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/serveur/www/gems/GEMS/media; # your Django project's media files - amend as required
}
location /static {
alias /home/serveur/www/gems/GEMS/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/serveur/www/gems/uwsgi_params; # the uwsgi_params file you installed
}
}
settings.py:
TEMPLATE_DIRS = ('/home/serveur/www/gems/GEMS/templates'),
STATIC_URL = '/static/' #'/home/serveur/www/gems/GEMS/static/'
STATIC_ROOT = "/home/serveur/www/gems/GEMS/static/" #os.path.join(BASE_DIR, "static/")
MEDIA_ROOT = '/home/serveur/www/gems/GEMS/static/media'
STATICFILES_DIR = ('/home/serveur/www/gems/GEMS/static')
import django.contrib.auth
django.contrib.auth.LOGIN_URL = '/'
wsgi.py:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "GEMS.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
I launch uwsgi with:
uwsgi --http :8001 --wsgi-file GEMS/wsgi.py --chdir /home/serveur/www/gems/GEMS --virtualenv /home/serveur/www/gems --chmod-socket=666
Does anyone have an idea ?
Thanks