简体   繁体   English

WSGIDaemon进程语法错误-Mod_wsgi django ImportError:没有名为django.core.wsgi的模块

[英]WSGIDaemon Process syntax error - Mod_wsgi django ImportError: No module named django.core.wsgi

I've just set up a testbed for migrating our site from managed, shared hosting to Digital Ocean. 我刚刚建立了一个测试平台,用于将我们的网站从托管共享托管迁移到Digital Ocean。 I built the service up, because I wanted to get what was going on. 我建立了服务,因为我想了解发生了什么。 Currently, the django system works, and I can run the devserver mapped to 0.0.0.0:8000 and it serves content,but that's clearly not going to cut it for production though, and I want to make apache work. 当前,django系统可以运行,我可以运行映射到0.0.0.0:8000的devserver并提供内容,但是显然这不会削减它的生产量,我想使apache起作用。 Currently working out of a virtualenv called 'env', imaginatively enough. 目前,可以想象地在一个名为“ env”的虚拟环境中工作。

I've followed the Digital Ocean quick start for this, but suspect I'm falling foul of the need to know a bit more than it provides. 我遵循了Digital Ocean的快速入门指南 ,但是怀疑我对需要了解的知识不了解。 Apache is there and installed, and operating correctly (at least initially) - when I access the root IP for the droplet, I get the 'It works!' Apache在那里并且已经安装并且可以正常运行(至少在最初运行时)-当我访问Droplet的根IP时,我得到了“有效!” message. 信息。 So, both bits work, but when I come to modify nano /etc/apache2/sites-enabled/000-default and restart, I get the message that: 因此,这两个位都起作用,但是当我修改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!

So it's failing at the first line of the following config(both paths are correct): 因此,它在以下配置的第一行失败(两个路径均正确):

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

The Traceback that I was getting originally was this: 我最初得到的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

I tried this very helpful answer , but it didn't seem to make any difference; 尝试了这个非常有帮助的答案 ,但似乎没有什么区别; one key thing is that I now can't reset the apache server as I normally would, as it won't start - so I'm uncertain if my changes are taking effect. 一个关键的事情是我现在无法像通常那样重置 apache服务器,因为它不会启动-因此我不确定我的更改是否生效。

I also removed and reinstalled mod_wsgi to see if that was the problem, reinstalling with apt-get install libapache2-mod-wsgi , and tried chmod 755 the wsgi.py file. 我还删除并重新安装了mod_wsgi以查看是否是问题所在,使用apt-get install libapache2-mod-wsgi重新apt-get install libapache2-mod-wsgi ,并尝试使用chmod 755 wsgi.py文件。

As an aside - all of the versions of apache i've used before have had an httpd.conf file, but this doesn't seem to have one - running ps -ef | 顺便说一句-我以前使用过的所有Apache版本都有一个httpd.conf文件,但是似乎没有一个-运行ps -ef | grep apache just shows the error log and the 000-default mentioned above. grep apache仅显示错误日志和上面提到的000-default。

Full default-000 is: 完整的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>

Similarly, i'm not using mod_python (as per Graeme's comment on the main question , and I can import django.core.wsgi manually in the shell. 同样,我没有使用mod_python(根据Graeme对主要问题的评论我可以在shell中手动导入django.core.wsgi

如评论中所述,您需要在重新安装mod-wsgi后通过执行sudo a2enmod wsgi来启用它。

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

相关问题 在Anaconda内部的Python上使用mod_wsgi配置Django时出错:“ImportError:没有名为django.core.wsgi的模块” - Error while configuring Django with mod_wsgi on Python inside Anaconda: “ImportError: No module named django.core.wsgi” ImportError:没有名为django.core.wsgi的模块 - ImportError: No module named django.core.wsgi “ ImportError:没有名为django.core.wsgi的模块” apache错误 - “ImportError: No module named django.core.wsgi” apache error 导入错误:没有用于 wsgi 服务器设置的名为 django.core.wsgi 的模块 - ImportError: No module named django.core.wsgi for wsgi server setting ImportError:使用nginx部署时,没有名为django.core.wsgi的模块 - ImportError: No module named django.core.wsgi when deploying with nginx Apache Django应用程序:ImportError:没有名为django.core.wsgi的模块 - Apache Django app: ImportError: No module named django.core.wsgi Django-ImportError:没有名为django.core.wsgi的模块 - Django - ImportError : no module named django.core.wsgi App Engine + Django:ImportError:没有名为django.core.wsgi的模块 - App Engine + Django: ImportError: No module named django.core.wsgi ImportError:Elastic Beanstalk中没有名为django.core.wsgi的模块 - ImportError: No module named django.core.wsgi in Elastic Beanstalk 导入错误:没有名为 django.core.wsgi 的模块(ubuntu) - ImportError: No module named django.core.wsgi (ubuntu)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM