When using uwsgi to render python on nginx, you may use the following command: 
uwsgi --socket mysite.sock --wsgi-file mysite/wsgi.py --chmod-socket=664

Well, you may encounter an exception: ImportError: No module named django.core.handlers.wsgi
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1838)
spawned uWSGI worker 1 (pid: 1839, cores: 1)
Traceback (most recent call last):
  File "./mysite.py", line 7, in <module>
    import django.core.handlers.wsgi
ImportError: No module named django.core.handlers.wsgi
unable to load app SCRIPT_NAME=django.udm.local|

Well, the solution is simple. 

I've changed the mysite.py file and added the paths to django and the python libs
import os, sys

sys.path.append(os.path.dirname(__file__))
sys.path.append('/usr/lib/python2.7/dist-packages')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

Another problem you may also encounter is : 
2014/01/31 23:59:50 [crit] 10016#0: *8 connect() to unix:///home/zheng/Downloads/testdjango/testdjango.sock failed (13: Permission denied) 

Just change user to www-data if your nginx set the user to www-data. The corresponding command is : 
sudo su www-data






0 comments

Popular Posts

无觅相关文章插件,迅速提升网站流量