我已经尝试了很多,觉得自己被卡住了,无法到达任何地方Apache给出了一个错误
ModuleNotFoundError:没有名为“ wearpretty.settings”的模块
我正在使用 python 3.6, Django2.1, apache2, libapache2-mod-wsgi-py3
下面是正在使用的文件。
import os
from django.core.wsgi import get_wsgi_application
os.environ["DJANGO_SETTINGS_MODULE"] = "wearpretty.settings"
application = get_wsgi_application()
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName lhwearpretty.com
ServerAlias www.lhwearpretty.com
DocumentRoot /var/www/myprojects/wearpretty/wearpretty/wearpretty
<Directory /var/www/myprojects/wearpretty/wearpretty/wearpretty>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess lhwearpretty.com python-home=/var/www/myprojects/wearpretty/venv python-path=/var/www/myprojects/wearpretty
WSGIProcessGroup lhwearpretty.com
WSGIScriptAlias / /var/www/myprojects/wearpretty/wearpretty/wearpretty/wsgi.py
Alias /static/ /var/www/myprojects/wearpretty/wearpretty/static/
<Directory /var/www/myprojects/wearpretty/wearpretty/static>
Require all granted
</Directory>
</VirtualHost>
答案 0 :(得分:1)
您的 DocumentRoot 应该是一个文件夹(负1 /wearpretty
),而 WSGIDaemonProcess 中的 python-path var应该是一个文件夹down(加1 /wearpretty
):它们必须指向您的Django项目根目录。
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName lhwearpretty.com
ServerAlias www.lhwearpretty.com
DocumentRoot /var/www/myprojects/wearpretty/wearpretty
<Directory /var/www/myprojects/wearpretty/wearpretty/wearpretty>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess lhwearpretty.com python-home=/var/www/myprojects/wearpretty/venv python-path=/var/www/myprojects/wearpretty/wearpretty
WSGIProcessGroup lhwearpretty.com
WSGIScriptAlias / /var/www/myprojects/wearpretty/wearpretty/wearpretty/wsgi.py
Alias /static /var/www/myprojects/wearpretty/wearpretty/static/
<Directory /var/www/myprojects/wearpretty/wearpretty/static>
Require all granted
</Directory>
</VirtualHost>
此外,我建议添加此Directory节点:
<Directory /var/www/myprojects/wearpretty/wearpretty>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
答案 1 :(得分:1)
当我自己开始时,我发现目录的命名存在一些问题。 第一次开始的任何人都应该知道,您不能使用您的站点目录名称作为您的项目名称。 所以我改变了。
Sub SumCol()
For x = 2 To 6
Cells(7, x).FormulaR1C1 = Cells(4, x).Value + Cells(6, x).Value
Next x
End Sub
Site Dir = /var/www/myprojects/wearpretty
Project Dir = /var/www/myprojects/wearpretty/wearpretty
venv = /var/www/myprojects/wearpretty/venv
Site Dir = /var/www/myprojects/wearpretty
Project Dir = /var/www/myprojects/wearpretty/mysite
venv = /var/www/myprojects/wearpretty/venv
希望这对其他人也有帮助。