Guniorn没有展示多个django网站

时间:2016-03-02 00:54:48

标签: python django nginx gunicorn

我正在使用Gunicorn在Ubuntu VPS上托管一个网站。我的第一个网站工作正常,但当我尝试使用第二个网站的相同设置时,它给我错误“BAD REQUEST 400”。对于第一个站点,我没有使用虚拟环境。但对于第二个网站,我正在使用虚拟环境。以下是我对两个网站的gunciorn的设置。

Site1设置为:

description "Gunicorn daemon for Django project with no virtual environment"

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

# If the process quits unexpectadly trigger a respawn
respawn

setuid django
setgid django
chdir /home/django

exec gunicorn \
    --name=django_project \
    --pythonpath=django_project \
    --bind=127.0.0.1:9000 \
    --config /etc/gunicorn.d/gunicorn.py \
    django_project.wsgi:application

我的第二个网站设置如下:

description "Gunicorn daemon for Django project with virtual environment"

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

# If the process quits unexpectedly trigger a respawn
respawn

setuid django
setgid django
chdir /home/django/venv

exec venv/bin/gunicorn \
    --name=django_project2\
    --pythonpath=django_project2\
    --bind=127.0.0.1:9500 \
    --config /etc/gunicorn.d/gunicorn.py \
    django_project2.wsgi:application

我的第一个网站没有在Django用户文件夹(/home/django/django_project)下托管的虚拟环境。我的第二个网站位于(/home/django/venv/django_project2)位置。我可以使用命令gunicorn --bind domain.com:9500 domain.wsgi:application将我的第二个站点与端口9500连接,但不能连接到域名。但我不能绕过端口绑定。我认为在新项目中我唯一不同的是使用virtualenv。任何人都可以帮助解释为什么它不能在virtualenv中工作?当我使用命令“gunicorn django_project2.wsgi:application --bind domain.com 9500”时,我可以打开我的域名,输入端口号,如domain.com:9500。但是当我使用127.0.0.1:9500时,它没有正确绑定。请告知virtualenv需要进行哪些更改,以及我是否使用错误的参数绑定gunicorn。

0 个答案:

没有答案