我有一个在我的服务器上运行的python应用程序(具体的Django)。在昨天之前,它成功运行在mod-wsgi下的apache下,几乎没有问题。我有两个主要的原因切换到nginx的:uwsgi服务没有启动
- 性能 - 下nginx的,我对每个请求几乎一半时间
- 两个应用程序一起未成功apache下运行 - nginx的
- 第三个原因解决对我来说更好的配置
我有一个uwsgi服务的问题。首先,我将包括应用程序的WSGI文件:
import os
import sys
path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
if path not in sys.path:
sys.path.append(path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "usporion.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
然后,我有init的应用uwsgi.ini文件,位于/etc/uwsgi/apps-enabled/usporion.ini
下:
[uwsgi]
plugins = python
uid = www-data
gid = www-data
uwsgi-socket = /srv/sockets/usporion.sock
chmod-socket = 664
chdir = /srv/www/usporion
pythonpath = /srv/www/usporion
module = usporion.wsgi
env = DJANGO_SETTINGS_MODULE=usporion.settings
logdate = True
logto = /var/log/uwsgi/usporion.log
#daemonize = /var/log/uwsgi/usporion.log
vacuum = True
max-requests = 1000
processes = 5
threads = 10
workers = 5
vhost = True
注:我已经试过有守护进程注释掉(但这不适用于当前的使用情况)。
最后,我有这样的nginx的配置:
upstream django {
server 95.168.193.219:80;
}
server {
listen 95.168.193.219:80;
server_name usporion.cz;
return 301 $scheme://www.usporion.cz$request_uri;
}
server {
listen 95.168.193.219:80;
server_name www.usporion.cz;
charset utf-8;
client_max_body_size 100M;
location /media {
alias /srv/www/usporion/media;
expires 1d;
}
location /static {
alias /srv/www/usporion/static;
expires 1d;
}
location/{
root /srv/www/usporion;
include uwsgi_params;
uwsgi_pass unix:///srv/sockets/usporion.sock;
}
}
运行命令uwsgi --ini /etc/uwsgi/apps-enabled/usporion.ini
工作正常,我能看到的应用程序工作在网络上。但是,如果我做service uwsgi start
,服务没有启动(FAIL)没有消息,我无法找到日志中的任何内容。在启用了应用程序的情况下运行此服务时没有usporion.ini
工作正常。
我会很高兴的任何帮助,我可以避免在屏幕下运行uwsgi“服务”,但作为正常服务运行。
这里是DIST信息:
[email protected][name]:/etc/nginx/sites-enabled# uname -a
Linux [name] 2.6.32-5-amd64 #1 SMP Sun Sep 23 10:07:46 UTC 2012 x86_64 GNU/Linux
[email protected][name]:/etc/nginx/sites-enabled# cat /etc/debian_version
6.0.7
[email protected][name]:/etc/nginx/sites-enabled# nginx -v
nginx version: nginx/1.2.6
[email protected][name]:/etc/nginx/sites-enabled# uwsgi --version
1.2.3-debian
[email protected][name]:/etc/nginx/sites-enabled# python --version
Python 2.7.3
最后,如果有人想给我一些建议配置(我是新来的nginx的,它的欢迎),这是8核Xeon服务器2.4 GHz的16GB的RAM,其中一半是为这个应用程序保留。
有同样的问题,但不同的原因。对我来说,评论“listen”指令允许uwsgi启动。没有错误消息。有趣的追踪! – Homer6