我看过this。所以,我安装了mod_wsgi,virtualenv(virtualenv ENV
)。 (Django 1.4,ubuntu服务器)
的/ etc / apache2的/位点可用/ mysite的:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
WSGIDaemonProcess example.com python-path=/home/user/cars/cars:/home/user/cars/ENV/lib/python2.7/site-packege
WSGIScriptAlias / /home/user/cars/cars/wsgi.py
<Directory /home/user/cars/cars>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
</VirtualHost>
WSGIPythonPath /home/user/cars/ENV/lib/python2.7/site-packeges
我有内部服务器错误
在 /var/log/apache2/error.log中:
mod_wsgi (pid=3012): Exception occurred processing WSGI script '/home/user/cars/cars/wsgi.py'.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__
self.load_middleware()
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 95, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'cars.settings' (Is it on sys.path?): No module named cars.settings
请帮助我,我从未使用mod_wsgi配置Django。这是我的第一个项目
的更新 :
Alias /favicon.ico /home/user/cars/files/static_content/favicon.ico
AliasMatch ^/([^/]*\.css) /home/user/cars/files/static_content/css/$1
Alias /static/ /home/user/cars/files/static_content/
<Directory /home/user/cars/files/static_content>
Order deny,allow
Allow from all
</Directory>
答案 0 :(得分:1)
您缺少WSGIProcessGroup指令,因此未使用WSGIDaemonProcess及其python-path选项。正在使用WSGIPythonPath(仅适用于嵌入模式)中设置的路径,并且您没有设置项目的位置。即使对于WSGIDaemonProcess的python-path,你仍然有错误的路径。
尝试:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
WSGIDaemonProcess example.com python-path=/home/user/cars:/home/user/cars/ENV/lib/python2.7/site-packages
WSGIProcessGroup example.com
WSGIScriptAlias / /home/user/cars/cars/wsgi.py
<Directory /home/user/cars/cars>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
</VirtualHost>
注意到对python-path的更改以及WSGIProcessGroup的添加。