Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.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 带gunicorn的virtualenv不工作_Python_Django_Virtualenv_Gunicorn_Digital Ocean - Fatal编程技术网

Python 带gunicorn的virtualenv不工作

Python 带gunicorn的virtualenv不工作,python,django,virtualenv,gunicorn,digital-ocean,Python,Django,Virtualenv,Gunicorn,Digital Ocean,我正在开发一个django项目,我正在digitalocean服务器中的实例化(droplet)中进行,在实例化(droplet)中创建(通过选择一个项目)ubuntu服务器14.04+django 到目前为止还不错,但在使用virtualenv配置实例时 正如文件所说 无法识别virtualenv,因为在安装应用程序(使用pip安装程序)时,例如“django framework rest”,无法识别该应用程序,并且会抛出500个错误,因为没有此类应用程序 我也看到了这个帖子 其中提到了对配置

我正在开发一个django项目,我正在digitalocean服务器中的实例化(droplet)中进行,在实例化(droplet)中创建(通过选择一个项目)ubuntu服务器14.04+django

到目前为止还不错,但在使用virtualenv配置实例时 正如文件所说 无法识别virtualenv,因为在安装应用程序(使用pip安装程序)时,例如“django framework rest”,无法识别该应用程序,并且会抛出500个错误,因为没有此类应用程序

我也看到了这个帖子 其中提到了对配置文件的修改,您必须在其中分配在virtualenv中创建的新gunicorn的地址,但在服务重新启动时,它抛出了一个错误502:/

/* structure directory*/
/home/django
            /myproject (django)
            /envs/myapp (virtualenvs)


/* Gunicorn file */
description "Gunicorn daemon for Django project"

start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!12345]

respawn

setuid django
setgid django
chdir /home/django

exec gunicorn \ (**Here is where you change the url and gave 502 error)
   --name=myproject \
   --pythonpath=myproject \
   --bind=0.0.0.0:9000 \
   --config /etc/gunicorn.d/gunicorn.py \
   conf.wsgi:application

不知道为什么会出现这种情况?有人遇到过这样的情况,可以帮我解决这个问题。

我不明白你说的URL是什么意思,virtualenv与URL无关。您链接到的答案提供了解决方案:当我设置gunicorn时,您需要显式启动安装在virtualenv内部的gunicorn,使用
exec/path/to/my/virtualenv/bin/gunicorn…

,我输入了以下路径:1-/home/django/envs/myproject/bin/gunicorn 2-envs/myproject/bin/gunicorn 3-/envs/myproject/bin/gunicorn在我重新启动gunicorn后仍然得到错误502只有exec被更改了吗?我正在修改的一个或多个文件是:/etc/init/gunicorn.conf502是代理错误。nginx是否代理到:9000?nginx和gunicorn错误日志显示了什么?访问xxx.xxx.xxx.101---[03/Dec/2014:09:39:58-0500]“GET/HTTP/1.1”502583“-”Mozilla/5.0(Macintosh;Intel Mac OS X 10_10_1)AppleWebKit/537.36(KHTML,如Gecko)Chrome/39.0.2171.71 Safari/537.36“错误2014/12/03 09:58:0:*1连接失败(111:连接被拒绝)连接到上游时,客户端:xxx.xxx.xxx.101,服务器:\请求:“GET/HTTP/1.1”,上游:,主机:“myproject.com”myproject.com主机仅为参考