在apache上部署django:没有名为Portfolio.settings

时间:2016-11-21 19:06:38

标签: python django apache2 mod-wsgi django-1.9

我在/var/Django/Portfolio中获得了我的项目,同时在/var/Django/env中拥有了virtualenv。除了我在settings.py中设置DEBUG = False之外,它只是一个没有任何更改的新项目。 Virtualenv安装了Django 1.9.15和Python2.7。当我在调试模式下使用runserver运行项目时,站点显示正常,但是当我尝试部署并打开站点时,我收到500内部服务器错误。查看日志文件时会显示 ImportError: No module named settings

tail -f /var/log/apache2/error.log
[Mon Nov 21 19:04:51.009198 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Mon Nov 21 19:04:51.009538 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]   File "/var/www/Django/env/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
[Mon Nov 21 19:04:51.010080 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]     self._setup(name)
[Mon Nov 21 19:04:51.010415 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]   File "/var/www/Django/env/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
[Mon Nov 21 19:04:51.011209 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]     self._wrapped = Settings(settings_module)
[Mon Nov 21 19:04:51.011567 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]   File "/var/www/Django/env/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__
[Mon Nov 21 19:04:51.012105 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]     mod = importlib.import_module(self.SETTINGS_MODULE)
[Mon Nov 21 19:04:51.012454 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Mon Nov 21 19:04:51.013096 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]     __import__(name)
[Mon Nov 21 19:04:51.013550 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0] ImportError: No module named settings

就像我说我没有改变任何东西,只是用startproject命令创建了项目。

我的/etc/apache2/sites-enabled/000-default.conf文件添加了以下设置(之前是默认设置):

WSGIDaemonProcess folio python-path=/var/www/Django:/var/www/Django/env/lib/python2.7/site-packages
WSGIProcessGroup folio 
WSGIScriptAlias / /var/www/Django/Portfolio/Portfolio/wsgi.py
<Directory /var/www/Django/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

这是我在var / www /:

下的文件夹结构
.
.env/
./Portfolio/
./Portfolio./manage.py
./Portfolio./__init__.py
./Portfolio./Portfolio
./Portfolio./Portfolio/settings.pyc
./Portfolio./Portfolio/urls.py
./Portfolio./Portfolio/urls.pyc
./Portfolio./Portfolio/__init__.py
./Portfolio./Portfolio/settings.py
./Portfolio./Portfolio/wsgi.pyc
./Portfolio./Portfolio/__init__.pyc
./Portfolio./Portfolio/wsgi.py
./Portfolio./db.sqlite3
./Portfolio./__init__.pyc

0 个答案:

没有答案