- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我刚刚设置了一个测试平台,用于将我们的网站从托管共享托管迁移到 Digital Ocean。我建立了这项服务,因为我想了解正在发生的事情。目前,django 系统可以工作,我可以运行映射到 0.0.0.0:8000 的开发服务器并提供内容,但这显然不会影响生产,而且我想让 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
我最初得到的回溯是这样的:
[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 。
最佳答案
正如评论中提到的,您需要在重新安装 mod-wsgi 后启用它,方法是 sudo a2enmod wsgi
。
关于python - WSGIDaemon 进程语法错误 - Mod_wsgi django ImportError : No module named django. core.wsgi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27258835/
我是一名优秀的程序员,十分优秀!