我正在尝试在ubuntu上使用apache2.4 mod_wsgi部署django,但我发出错误。
首先安装软件包:sudo apt upgrade && sudo apt install virtualenv python-setuptools python3.6(from ppa) python3-pip python3.6-dev libapache2-mod-wsgi-py3 apache2 mysql-server
好的,全部正确安装。
所以,我创建了一个文件夹项目mkdir /mnt/g/development/matrix
创建virtualenv virtualenv --python=python3.6 env
并激活
从pip pip install django
安装django2.0 - 确定安装并检查
which python
的/ mnt /克/开发/基质/ env的/ bin中/蟒
python -V
Python 3.6.3
所以我在apache上创建了一个vhost
<VirtualHost *:80>
ServerName 127.0.0.50
ServerAlias matrix.local
DocumentRoot /mnt/g/development/matrix/framework
Alias /static /mnt/g/development/matrix/framework/static
Alias /media /mnt/g/development/matrix/framework/media
<Directory /mnt/g/development/matrix/framework/framework>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /mnt/g/development/matrix/framework/media/>
Require all granted
</Directory>
<Directory /mnt/g/development/matrix/framework/static/>
Require all granted
</Directory>
WSGIDaemonProcess matrix processes=2 threads=5 display-name=%{GROUP} python-path=/mnt/g/development/matrix/framework/:/mnt/g/development/matrix/env/lib/python3.6/site-packages
WSGIProcessGroup matrix
WSGIScriptAlias / /mnt/g/development/matrix/framework/framework/wsgi.py
</VirtualHost>
所以,我启动apache和mysql服务器,但是我给出了一个错误
(env)root @ WILLIAM:/ mnt / g / development / matrix#tail /var/log/apache2/error.log [Tue Jun 19 04:01:10.947533 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] mod_wsgi(pid = 14811):目标WSGI 脚本'/mnt/g/development/matrix/framework/framework/wsgi.py'不能 作为Python模块加载。 [Tue Jun 19 04:01:10.948034 2018] [:错误] [pid 14811] [remote 127.0.0.1:28540] mod_wsgi(pid = 14811):异常 发生了处理WSGI脚本 '/mnt/g/development/matrix/framework/framework/wsgi.py'。 [Tue Jun 19 04:01:10.948034 2018] [:错误] [pid 14811] [remote 127.0.0.1:28540] 追溯(最近的呼叫最后):[Tue Jun 19 04:01:10.948034 2018] [:error] [pid 14811] [remote 127.0.0.1:28540]文件 “/mnt/g/development/matrix/framework/framework/wsgi.py”,第12行,在 [Tue Jun 19 04:01:10.948534 2018] [:错误] [pid 14811] 来自django.core.wsgi import的[remote 127.0.0.1:28540] get_wsgi_application [Tue Jun 19 04:01:10.948534 2018] [:error] [pid 14811] [remote 127.0.0.1:28540]文件 “/mnt/g/development/matrix/env/lib/python3.6/site-packages/django/init.py” 第1行,[Tue Jun 19 04:01:10.949034 2018] [:错误] [pid 14811] [django.utils.version导入的[remote 127.0.0.1:28540] get_version [Tue Jun 19 04:01:10.949034 2018] [:error] [pid 14811] [remote 127.0.0.1:28540]文件 “/mnt/g/development/matrix/env/lib/python3.6/site-packages/django/utils/version.py” 第61行,[Tue Jun 19 04:01:10.949534 2018] [:错误] [pid 14811] [remote 127.0.0.1:28540] @ functools.lru_cache()[Tue Jun 19 04:01:10.949534 2018] [:错误] [pid 14811] [remote 127.0.0.1:28540] AttributeError:'module'对象没有属性'lru_cache'
如果我在Ubuntu 14.04上使用与Python3.4.5相同的代码,则默认工作。 在哪里我错了?
我的WSGIDeamonProcesses路径是对的吗?
由于