简体   繁体   English

Django apache + mod_wsgi openPanel virtualenv设置

[英]Django apache+mod_wsgi openPanel virtualenv setup

I am deploying two django sites on apache with mod_wsgi. 我正在使用mod_wsgi在apache上部署两个django站点。 I have installed two virtualenvs: 我已经安装了两个virtualenvs:

/home/user/virtualenv1
/home/user/virtualenv2

Now my problem is configuring the wsgi apps to use these, for instance I have: 现在,我的问题是将wsgi应用程序配置为使用这些应用程序,例如,我有:

/var/www/djangosite1
/var/www/djangosite1/project1/wsgi.py

/var/www/djangosite2
/var/www/djangosite2/project2/wsgi.py

My apache is configured via openPanel so I have my VirtualHosts included like this: 我的apache是​​通过openPanel配置的,因此我的VirtualHosts如下所示:

/etc/apache2/openpanel.d/project1.com.inc/django.conf /etc/apache2/openpanel.d/project1.com.inc/django.conf

<VirtualHost *:80>
ServerName project1

WSGIDaemonProcess project1 user=user group=www-data processes=2 threads=25 python-path=/home/user/virtualenv1/lib/python2.6/site-packages
WSGIProcessGroup project1
</VirtualHost>

/etc/apache2/openpanel.d/project2.com.inc/django.conf /etc/apache2/openpanel.d/project2.com.inc/django.conf

<VirtualHost *:80>
ServerName project2

WSGIDaemonProcess project2 user=user group=www-data processes=2 threads=25 python-path=/home/user/virtualenv2/lib/python2.6/site-packages
WSGIProcessGroup project2
</VirtualHost>

Now I restart apache: 现在,我重新启动apache:

service apache2 reload

Which doesn't give me any errors, next I tail the error log and visit my project.com 这不会给我任何错误,接下来我将显示错误日志并访问我的project.com

tail -f /var/log/apache2/error.log

Which gives me this error 这给我这个错误

ImportError: No module named south

When I install south on my system (not in a virtualenv) all works, but offcourse the idea is not to contaminate the system but use a seperate virtual env for each site. 当我在系统上安装南方软件时(不是在virtualenv中),所有工作正常,但是偏离路线的想法不是污染系统,而是为每个站点使用单独的虚拟环境。

I think I'm missing the obvious.. 我想我想念的很明显..

也许您需要在virtualenv上检查当前的South路径,并先前添加到sys.path中。

Try enabling your virtualenv in the wsgi file rather than adding site-packages in the vhost. 尝试在wsgi文件中启用virtualenv,而不是在vhost中添加站点包。

Add the following to the top of your wsgi files. 将以下内容添加到wsgi文件的顶部。

# Start the correct virtualenv
activate_this = '/home/user/virtualenv1/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

(I'm not sure if this is the official way to do things but its certainly something I have had working many times.) (我不确定这是否是做事的正式方式,但肯定是我已经工作了很多次了。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM