我尝试在nginx + uwsgi上运行django的webserver,os - debian(3.1.0-1-amd64 x86_64)nginx 1.1.8-1,uwsgi 0.9.8.3-1配置:
<uwsgi>
<socket>/tmp/uwsgi.sock</socket>
<process>1</process>
<master/>
<enable-threads/>
<uid>33</uid>
<gid>33</gid>
<pidfile>/tmp/uwsgi.pid</pidfile>
</uwsgi>
Run Code Online (Sandbox Code Playgroud)
在文件/etc/uwsgi/apps-enabled/webapp.xml nginx配置中
location / {
uwsgi_pass unix:///tmp/uwsgi.sock;
include uwsgi_params;
uwsgi_param UWSGI_SCRIPT webapp;
uwsgi_param UWSGI_CHDIR /data/web/webapp/webapp;
}
Run Code Online (Sandbox Code Playgroud)
所有projet在/ data/web/webapp/webapp /,这里是setting.py,网址等.在/data/web/webapp/webapp/webapp.py中
import sys, os
import django.core.handlers.wsgi
sys.path.insert(0, '/data/web/webapp/webapp')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
application = django.core.handlers.wsgi.WSGIHandler()
Run Code Online (Sandbox Code Playgroud)
uid和gid 33它是www-data用户尝试运行uwsgi as
root#uwsgi -s /var/run/uwsgi.sock -x /etc/uwsgi/apps-enabled/webapp.xml
[uWSGI] parsing config file /etc/uwsgi/apps-enabled/webapp.xml
*** Starting uWSGI 0.9.8.3-debian (64bit) on [Wed Dec 14 21:42:02 2011] ***
compiled with version: 4.6.1 on 27 …Run Code Online (Sandbox Code Playgroud)