我刚刚设置了一个测试平台,用于将我们的网站从托管,共享托管迁移到Digital Ocean。我建立了服务,因为我想得到正在发生的事情。目前,django系统工作,我可以运行映射到0.0.0.0:8000的devserver并且它提供内容,但是显然不会削减它用于生产,我想让apache工作。目前正在创造一种名为“env'”的虚拟媒体,充满想象力。
我已经跟着Digital Ocean quick start了解了这一点,但我怀疑我是否需要知道比它提供的更多的东西。 Apache在那里安装并运行正常(至少在最初阶段) - 当我访问Droplet的根IP时,我得到了它的工作!'信息。所以,这两个位都有效,但当我来修改nano /etc/apache2/sites-enabled/000-default
并重新启动时,我收到的信息是:
Syntax error on line 2 of /etc/apache2/sites-enabled/000-default:
Invalid command 'WSGIDaemonProcess', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
failed!
所以它在以下配置的第一行失败(两条路径都正确):
WSGIDaemonProcess processname python-path=/var/www/path/tosite:/var/www/env/lib/python2.7/site-packages
WSGIProcessGroup processname
WSGIScriptAlias / /var/www/path/to/project/wsgi.py
我最初获得的Traceback是这样的:
[Tue Dec 02 13:47:48 2014] [notice] Apache/2.2.22 (Debian) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Tue Dec 02 13:47:50 2014] [error] [clientIP] mod_wsgi (pid=18936): Target WSGI script '/var/www/project/projectv2/projectv2/wsgi.py' cannot be loaded as Python module.
[Tue Dec 02 13:47:50 2014] [error] [clientIP] mod_wsgi (pid=18936): Exception occurred processing WSGI script '/var/www/project/projectv2/projectv2/wsgi.py'.
[Tue Dec 02 13:47:50 2014] [error] [clientIP] Traceback (most recent call last):
[Tue Dec 02 13:47:50 2014] [error] [clientIP] File "/var/www/project/projectv2/projectv2/wsgi.py", line 15, in <module>
[Tue Dec 02 13:47:50 2014] [error] [clientIP] from django.core.wsgi import get_wsgi_application
[Tue Dec 02 13:47:50 2014] [error] [clientIP] ImportError: No module named django.core.wsgi
[Tue Dec 02 13:47:51 2014] [error] [clientIP] mod_wsgi (pid=18936): Target WSGI script '/var/www/project/projectv2/projectv2/wsgi.py' cannot be loaded as Python module.
[Tue Dec 02 13:47:51 2014] [error] [clientIP] mod_wsgi (pid=18936): Exception occurred processing WSGI script '/var/www/project/projectv2/projectv2/wsgi.py'.
[Tue Dec 02 13:47:51 2014] [error] [clientIP] Traceback (most recent call last):
[Tue Dec 02 13:47:51 2014] [error] [clientIP] File "/var/www/project/projectv2/projectv2/wsgi.py", line 15, in <module>
[Tue Dec 02 13:47:51 2014] [error] [clientIP] from django.core.wsgi import get_wsgi_application
[Tue Dec 02 13:47:51 2014] [error] [clientIP] ImportError: No module named django.core.wsgi
[Tue Dec 02 13:47:51 2014] [error] [clientIP] mod_wsgi (pid=18936): Target WSGI script '/var/www/project/projectv2/projectv2/wsgi.py' cannot be loaded as Python module.
[Tue Dec 02 13:47:51 2014] [error] [clientIP] mod_wsgi (pid=18936): Exception occurred processing WSGI script '/var/www/project/projectv2/projectv2/wsgi.py'.
[Tue Dec 02 13:47:51 2014] [error] [clientIP] Traceback (most recent call last):
[Tue Dec 02 13:47:51 2014] [error] [clientIP] File "/var/www/project/projectv2/projectv2/wsgi.py", line 15, in <module>
[Tue Dec 02 13:47:51 2014] [error] [clientIP] from django.core.wsgi import get_wsgi_application
[Tue Dec 02 13:47:51 2014] [error] [clientIP] ImportError: No module named django.core.wsgi
我tried this very helpful answer,但它似乎没有任何区别;一个关键的事情是,我现在无法像通常那样重置 apache服务器,因为它不会启动 - 所以我不确定我的更改是否生效
我还删除并重新安装mod_wsgi以查看是否存在问题,使用apt-get install libapache2-mod-wsgi
重新安装,并尝试使用chmod 755 wsgi.py文件。
顺便说一下 - 之前使用的所有apache版本都有一个httpd.conf文件,但是这似乎没有 - 运行ps -ef | grep apache只显示错误日志和上面提到的000-default。
完全默认-000是:
<VirtualHost *:80>
WSGIDaemonProcess project python-path=/var/www/project/projectv2:/var/www/env/lib/python2.7/site$
WSGIProcessGroup project
WSGIScriptAlias / /var/www/project/projectv2/projectv2/wsgi.py
ServerAdmin system@project.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
同样,我没有在shell中使用mod_python(根据Graeme's comment on the main question和I can import django.core.wsgi manually。
答案 0 :(得分:1)
如评论中所述,您需要在重新安装后启用mod-wsgi,方法是执行sudo a2enmod wsgi
。