我已经看到很多以前的消息与我的问题有关,但没有答案可以摆脱我的“500服务器内部错误”,所以我尝试发布我的conf来获得帮助 .
错误信息:
[星期五6月24日17:05:23.631270 2016] [authz_core:错误] [pid 15187:tid 140715758237440] [客户端127.0.0.1:47873] AH01630:客户端被服务器配置拒绝:/ home / www / waves / [Fri Jun 24 17:05:23.631568 2016] [:error] [pid 15186:tid 140715648984832] ['/home/marc/.virtualenvs/waves/lib/python2.7/site-packages','/ home / www / waves' ,'/usr/local/lib/python2.7/dist-packages/setuptools-20.6.7-py2.7.egg','/ usr / lib / python2.7','/ usr / lib / python2.7 / plat-x86_64-linux-gnu','/ usr / lib / python2.7 / lib -tk','/ usr / lib / python2.7 / lib-old','/ usr / lib / python2.7 / lib-dynload','/ usr / local / lib / python2.7 / record-packages','/ usr / lib / python2.7 / record-package','/ usr / lib / python2.7 / dad -packages / PILcompat','/ usr / lib / python2.7 / did-package / gtk-2.0','/ usr / lib / python2.7 / did-package /ubuntu -sso-client'] [6月24日星期五17: 05:23.631660 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] mod_wsgi(pid = 15186):目标WSGI脚本'/home/www/waves/waves_services/wsgi.py'不能作为Python模块加载 . [星期五6月24日17:05:23.631675 2016] [:错误] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] mod_wsgi(pid = 15186):处理WSGI脚本'/ home / www / waves /时发生异常waves_services / wsgi.py” . [Fri Jun 24 17:05:23.631686 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] Traceback(最近一次电话 Session ):[Fri Jun 24 17:05:23.631710 2016] [ :错误] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665]文件“/home/www/waves/waves_services/wsgi.py”,第18行,在[Fri Jun 24 17:05:23.631731 2016] [ :错误] [pid 15186:tid 140715648984832] [远程127.0.0.1:50665]来自django.core.wsgi import get_wsgi_application [Fri Jun 24 17:05:23.631743 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] ImportError:没有名为django.core.wsgi的模块
我的django应用程序没有加载在apache wsgi模式,我尝试了很多解决方案,但仍然无法正常工作 . 这是我的confs文件:虚拟主机:
<VirtualHost *:80>
ServerName dev.www.waves.com
ServerAlias www.waves.com
ServerAdmin webmaster@waves.com
DocumentRoot /home/www/waves
Alias media/ /home/www/waves/media/
Alias static/ /home/www/waves/static/
<Directory /home/www/waves>
Require all granted
</Directory>
<Directory /home/www/waves/staticfiles>
Require all granted
</Directory>
<Directory /home/www/waves/media>
Require all granted
</Directory>
WSGIDaemonProcess waves python-path=/home/marc/.virtualenvs/waves/lib/python2.7/site-packages:/home/www/waves
WSGIProcessGroup waves
WSGIScriptAlias /waves /home/www/waves/waves_services/wsgi.py
<Directory /home/www/waves/waves_services>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /home/marc/.virtualenvs/waves/lib/python2.7/>
Require all granted
</Directory>
我的wsgy.py内容:
from __future__ import unicode_literals
import os
import sys
import site
print sys.path
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "waves_services.settings.production")
application = get_wsgi_application()
我在apache错误日志中跟踪了sys.path内容,在sys.path中跟踪了virtualenv . Django安装在这个virtualenv中(我首先尝试安装django'全局'但错误只是转移到我的设置文件中包含的第一个'特定于应用程序'的导入:environ . 虚拟环境是使用virtualenvwrapper创建的(任何影响? )
我也试过改变virtualenv文件的所有权,改变了'执行'标志,但我仍然得到这个... 500服务器错误 .
我很想知道发生了什么! thanxs
1 回答
要检查的几件事 .
确保virtualenv有django(
pip freeze | grep django
)检查apache用户是否可以通过检查文件夹权限来访问virtualenv
如果您使用的是apache 2.4,请更改以下内容
Order deny,allow Allow from all
至
Require all granted
Edit suggested by @marcoooo (OP) :don 't put virtualenv base dir under any home dir which do not have ' x ' flag, apache www-data user won' t能够激活virtualenv ....许多人对e4c5的帮助,并保存了我的一天(和夜晚)