我安装了apache和mod_wsgi
模块来部署django
应用程序。
我的机器中有anaconda作为python发行版,所以我这样安装了mod_wsg:
$ ./configure --with-apxs=/usr/local/apache2/bin/apxs \
--with-python=ANACONDA_PATH/bin/python
$ make
$ make install
所以,我向mod_wsgi
表示要使用anaconda的蟒蛇。
然后,我将模块mod_wsgi
添加到apache2的httpd.conf
。
我将此添加到000-default.conf
Alias /static PATH_TO_MY_PROJECT/MYPROJECT/static
<Directory PATH_TO_MY_PROJECT/MYPROJECT/static>
Require all granted
</Directory>
<Directory PATH_TO_MY_PROJECT/MYPROJECT/MYPROJECT/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / PATH_TO_MY_PROJECT/MYPROJECT/MYPROJECT/wsgi.py
我重启了apache,但是当我尝试在浏览器上运行localhost时,我收到了这个错误日志。
[Tue Jan 26 18:35:47.983537 2016] [wsgi:error] [pid 15034:tid 140139653007104] [client ::1:56161] mod_wsgi (pid=15034): Exception occurred processing WSGI script '/PATH_TO_MY_PROJECT//MY_PROJECT//wsgi.py'.
[Tue Jan 26 18:35:47.983685 2016] [wsgi:error] [pid 15034:tid 140139644614400] [client ::1:56162] mod_wsgi (pid=15034): Exception occurred processing WSGI script '/PATH_TO_MY_PROJECT//MY_PROJECT//wsgi.py'.
[Tue Jan 26 18:35:47.983706 2016] [wsgi:error] [pid 15034:tid 140139653007104] [client ::1:56161] Traceback (most recent call last):
[Tue Jan 26 18:35:47.983725 2016] [wsgi:error] [pid 15034:tid 140139644614400] [client ::1:56162] Traceback (most recent call last):
[Tue Jan 26 18:35:47.983746 2016] [wsgi:error] [pid 15034:tid 140139653007104] [client ::1:56161] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Tue Jan 26 18:35:47.983767 2016] [wsgi:error] [pid 15034:tid 140139644614400] [client ::1:56162] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Tue Jan 26 18:35:48.001509 2016] [wsgi:error] [pid 15034:tid 140139644614400] [client ::1:56162] self.load_middleware()
[Tue Jan 26 18:35:48.001556 2016] [wsgi:error] [pid 15034:tid 140139644614400] [client ::1:56162] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Tue Jan 26 18:35:48.013186 2016] [wsgi:error] [pid 15034:tid 140139644614400] [client ::1:56162] mw_class = import_by_path(middleware_path)
[Tue Jan 26 18:35:48.013231 2016] [wsgi:error] [pid 15034:tid 140139644614400] [client ::1:56162] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 31, in import_by_path
[Tue Jan 26 18:35:48.013291 2016] [wsgi:error] [pid 15034:tid 140139653007104] [client ::1:56161] self.load_middleware()
[Tue Jan 26 18:35:48.013332 2016] [wsgi:error] [pid 15034:tid 140139653007104] [client ::1:56161] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Tue Jan 26 18:35:48.013356 2016] [wsgi:error] [pid 15034:tid 140139653007104] [client ::1:56161] mw_class = import_by_path(middleware_path)
[Tue Jan 26 18:35:48.013381 2016] [wsgi:error] [pid 15034:tid 140139653007104] [client ::1:56161] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 31, in import_by_path
[Tue Jan 26 18:35:48.026342 2016] [wsgi:error] [pid 15034:tid 140139653007104] [client ::1:56161] error_prefix, module_path, class_name))
[Tue Jan 26 18:35:48.026630 2016] [wsgi:error] [pid 15034:tid 140139653007104] [client ::1:56161] ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class
[Tue Jan 26 18:35:48.037857 2016] [wsgi:error] [pid 15034:tid 140139644614400] [client ::1:56162] error_prefix, module_path, class_name))
[Tue Jan 26 18:35:48.037903 2016] [wsgi:error] [pid 15034:tid 140139644614400] [client ::1:56162] ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class
这里的问题是,mod_wsgi
指向/usr/lib/python2.7/dist-packages
,我需要它指向我在mod_wsgi安装中指定的anaconda的sites-packages。
有任何帮助吗?我会愉快地回答额外的问题。