I have a Django 1.6 application for testing purpose as shown:
media folder -> /home/josealejandro93/Desktop/Soporte/media
static folder -> /home/josealejandro93/Desktop/Soporte/static
root folder -> /home/josealejandro93/Desktop/Soporte # manage.py lives here!
I managed to configure uwsgi using this tutorial on Linux Arch and when I run
uwsgi --http :8000 --module soporte.wsgi
I can see my application running on localhost:8000
however by following the configuration instructions in the tutorial pointed above I wasn't able to serve static files so I tried a new configuration for my /etc/nginx/nginx.conf:
worker_processes 1;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
include /etc/nginx/mime.types;
root /home/josealejandro93/Desktop/Soporte;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
As you can see, that file is just a basic configuration file but I'm still not able to serve my static files.
Any idea on what am I doing wrong?
You should configure nginx to recognize and serve media and static files:
server {
listen 80;
server_name localhost;
location / {
include /etc/nginx/mime.types;
root /home/josealejandro93/Desktop/Soporte;
index index.html index.htm;
}
location /static/ {
alias /home/josealejandro93/Desktop/Soporte/static;
}
location /media/ {
alias /home/josealejandro93/Desktop/Soporte/media;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.