嗨,我需要在Nginx上部署一个django应用程序.我在我的fedora中安装了Nginx和python-flup我试试这个guide,但是Nginx无法读取我的静态文件.
在我的项目目录中,我使用此命令来运行fastcgi:
[nima@ca005 bank]$python ./manage.py runfcgi host=127.0.0.1 port=8080
[nima@ca005 bank]$
这是我在/ etc / Nginx / sites-enable /中的sample_project.conf:
server {
listen 80;
server_name 192.168.16.161;
access_log /var/log/Nginx/sample_project.access.log;
error_log /var/log/Nginx/sample_project.error.log;
# https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-production
location /static/ { # STATIC_URL
alias /home/nima/workspace/bank/media/; # STATIC_ROOT
expires 30d;
}
location /media/ { # MEDIA_URL
alias /home/nima/workspace/bank/meli/static/; # MEDIA_ROOT
expires 30d;
}
location / {
include fastcgi_params;
fastcgi_pass 127.0.0.1:8080;
fastcgi_split_path_info ^()(.*)$;
}
}
Nginx.conf:
# For more @R_677_4045@ion on configuration, see:
# * Official English Documentation: http://Nginx.org/en/docs/
# * Official Russian Documentation: http://Nginx.org/ru/docs/
user Nginx;
worker_processes 1;
error_log /var/log/Nginx/error.log;
#error_log /var/log/Nginx/error.log notice;
#error_log /var/log/Nginx/error.log info;
pid /run/Nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/Nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/Nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load config files from the /etc/Nginx/conf.d directory
# The default server is in conf.d/default.conf
include /etc/Nginx/conf.d/*.conf;
include /etc/Nginx/sites-enable/*;
}
我该怎么办?!
解决方法:
首先,如果你选择使用Nginx,那么使用gunicorn,它是最好的选择,如果你想使用Apache,那么你使用mod_wsgi.
This将向您展示如何使用gunicorn.只是告诉你它有多好,Instagram会使用gunicorn,因为它们声称它可以提供更好的性能.
设置gunicorn非常简单易行,这里的this教程为您提供了使其快速完成所需的所有必要条件.
This是他们的网站.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。