【发布时间】:2018-03-08 08:26:46
【问题描述】:
所以这让我发疯了,我有 python3、modwsgi、apache 和一个虚拟主机,它们工作得很好,因为我有几个其他 wsgi 脚本在服务器上工作得很好。我还有一个 django 应用程序,在我运行开发服务器时效果很好。
我已检查“ldd mod_wsgi.so”是否与 python3.5 正确链接
每当我尝试访问我的网站时,都会收到错误消息,并且 apache 日志指出: ImportError:没有名为“protectionprofiles”的模块 保护配置文件是我的站点名称以下是我的虚拟主机配置
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName <my ip>
WSGIScriptAlias /certs /var/www/scripts/CavsCertSearch/CavsCertSearch/certstrip.wsgi
WSGIScriptAlias /testcerts /var/www/scripts/CavsCertSearchTest/CavsCertSearch/certstriptest.wsgi
WSGIScriptAlias /protectionprofiles /var/www/protectionprofiles/protectionprofiles/wsgi.py
<Directory /var/www/protectionprofiles/protectionprofiles>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
我的站点应用程序是保护配置文件别名。我不知道问题是什么我已经尝试了几十个不同的 apache 教程,但它们似乎都不起作用。任何帮助是极大的赞赏。
------ 添加我尝试过的其他东西-------- 所以我在虚拟主机中添加了以下2个命令
WSGIDaemonProcess protectionprofiles python-path=/var/www/protectionprofiles/
WSGIProcessGroup protectionprofiles
不,我得到一个不同的错误
Error was: No module named 'django.db.backends.postgresql'
这是我的后端,但开发服务器工作正常?下面是我的数据库配置
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'USER': 'myuser',
'PASSWORD': 'abcd1234',
'HOST': '127.0.0.1',
'PORT': '5432',
'NAME': 'protectionprofile',
}
}
----另一个错误---- 偶尔我会得到
RuntimeError: populate() isn't reentrant
----另一个错误!!---现在当我更新时
WSGIDaemonProcess protectionprofiles python-path=/var/www/protectionprofiles/:/usr/lib/python3/dist-packages/django
我明白了
ImportError: cannot import name 'SimpleCookie'
---另一个奇怪的事情是当我有
WSGIProcessGroup protectionprofiles
启用我没有得到它找不到模块“protectionprofiles”的错误,但是当我的其他 wsgi 脚本不起作用时!他们只在那里没有的时候工作。对此的任何解释都会非常有帮助
【问题讨论】:
-
Django 安装在哪里?它是真的安装在您的系统 Python 安装中,还是您使用的是虚拟环境? mod_wsgi 是为哪个版本的 Python 编译的,您要使用哪个版本? modwsgi.readthedocs.io/en/develop/user-guides/…
-
django 是用 pip3 install django 安装的,我不认为我使用的是虚拟环境?一切都是用apt或pip安装的。此外,我所有不是 django 脚本的 wsgi 脚本(另外两个)都可以正常工作。让我弄清楚一切的版本
-
populate()错误是尝试加载 WSGI 应用程序时发生的错误的副作用。所以此时可以忽略。 -
你是否安装了 Python 包
psycopg2? -
您应该需要为安装到 Python 安装中的包添加任何额外的路径。这表明您的 mod_wsgi 实际上并未针对您想要的 Python 安装进行编译。找到
mod_wsgi.so模块并在其上运行ldd以查看它与 modwsgi.readthedocs.io/en/develop/user-guides/… 链接的内容
标签: django apache python-3.x mod-wsgi