Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用uwsgi和nginx设置django_Python_Django_Nginx_Uwsgi - Fatal编程技术网

Python 使用uwsgi和nginx设置django

Python 使用uwsgi和nginx设置django,python,django,nginx,uwsgi,Python,Django,Nginx,Uwsgi,我正在尝试使用uwsgi和nginx为django 1.5应用程序提供服务。下面是我的ini文件 [uwsgi] # variables projectname = mysite projectdomain = mysite.in base = /home/shwetanka/projects/me/mysite # config plugins = python master = true protocol = uwsgi env = DJANGO_SETTINGS_MODULE=%(bas

我正在尝试使用uwsgi和nginx为django 1.5应用程序提供服务。下面是我的ini文件

[uwsgi]
# variables
projectname = mysite
projectdomain = mysite.in
base = /home/shwetanka/projects/me/mysite

# config
plugins = python
master = true
protocol = uwsgi
env = DJANGO_SETTINGS_MODULE=%(base)/%(projectname).settings
#pythonpath = %(base)/src/%(projectname)
module = %(base)/mysite/wsgi.py
socket = 127.0.0.1:8889
logto = %(base)/logs/uwsgi.log
#below line runs it as a daemon in background
daemonize = /var/log/uwsgi/mysite.log
我在日志中得到了这个错误-

Sat Aug 31 14:05:35 2013 - *** Starting uWSGI 1.2.3-debian (64bit) on [Sat Aug 31 14:05:35 2013] ***
Sat Aug 31 14:05:35 2013 - compiled with version: 4.7.2 on 07 November 2012 03:49:52
Sat Aug 31 14:05:35 2013 - detected number of CPU cores: 4
Sat Aug 31 14:05:35 2013 - current working directory: /
Sat Aug 31 14:05:35 2013 - detected binary path: /usr/bin/uwsgi-core
Sat Aug 31 14:05:35 2013 - your memory page size is 4096 bytes
Sat Aug 31 14:05:35 2013 - detected max file descriptor number: 1024
Sat Aug 31 14:05:35 2013 - lock engine: pthread robust mutexes
Sat Aug 31 14:05:35 2013 - uwsgi socket 0 inherited UNIX address /run/uwsgi/app/mysite/socket fd 3
Sat Aug 31 14:05:35 2013 - uwsgi socket 1 inherited INET address 127.0.0.1:8889 fd 5
Sat Aug 31 14:05:35 2013 - Python version: 2.7.4 (default, Apr 19 2013, 18:30:41)  [GCC 4.7.3]
Sat Aug 31 14:05:35 2013 - *** Python threads support is disabled. You can enable it with --enable-threads ***
Sat Aug 31 14:05:35 2013 - Python main interpreter initialized at 0xd36dc0
Sat Aug 31 14:05:35 2013 - your server socket listen backlog is limited to 100 connections
Sat Aug 31 14:05:35 2013 - *** Operational MODE: preforking ***
ImportError: Import by filename is not supported.
Sat Aug 31 14:05:35 2013 - unable to load app 0 (mountpoint='') (callable not found or import error)
Sat Aug 31 14:05:35 2013 - *** no app loaded. going in full dynamic mode ***
Sat Aug 31 14:05:35 2013 - *** uWSGI is running in multiple interpreter mode ***
Sat Aug 31 14:05:35 2013 - gracefully (RE)spawned uWSGI master process (pid: 6093)
Sat Aug 31 14:05:35 2013 - spawned uWSGI worker 1 (pid: 6245, cores: 1)
Sat Aug 31 14:05:35 2013 - spawned uWSGI worker 2 (pid: 6246, cores: 1)
我如何让它工作

ImportError:不支持按文件名导入


--module
指令要求的是模块,而不是文件。您应该改用
--wsgi file

您需要使用:
--module mysite调用django模块。wsgi:application

别忘了添加:
--env DJANGO\u SETTINGS\u MODULE=mysite.SETTINGS

例如,工作命令行是(如果当前目录是项目主目录):

可以在上找到一些额外的信息和参数。

顺便说一下,这对我帮助很大。

如果您能正确使用
python manage.py runserver 0.0.0.0:8000

然后在同一目录下运行
uwsgi--http:8000--module mysite.wsgi
mysite
是django项目的名称

ref:

uwsgi:无法识别的选项'--module'。版本:2.0.18
uwsgi --socket mysite/zohosel.sock  --module mysite.wsgi:application --env DJANGO_SETTINGS_MODULE=mysite.settings --home=/path/to/your/venv --chmod-socket=666