我试图在我的Mac OS X 10.7狮子上设置石墨,我已经build立了Apache通过WSGI调用python石墨脚本,但是当我尝试访问它时,我从apache获取了一个forbiden并且在错误日志。
"client denied by server configuration: /opt/graphite/webapp/graphite.wsgi"
我已经检查过httpd.conf中允许的脚本位置,以及文件的权限,但看起来是正确的。 我需要做些什么来获得访问权限。 下面是httpd.conf,这几乎是石墨的例子。
<IfModule !wsgi_module.c> LoadModule wsgi_module modules/mod_wsgi.so </IfModule> WSGISocketPrefix /usr/local/apache/run/wigs <VirtualHost _default_:*> ServerName graphite DocumentRoot "/opt/graphite/webapp" ErrorLog /opt/graphite/storage/log/webapp/error.log CustomLog /opt/graphite/storage/log/webapp/access.log common WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120 WSGIProcessGroup graphite WSGIApplicationGroup %{GLOBAL} WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL} # XXX You will need to create this file! There is a graphite.wsgi.example # file in this directory that you can safely use, just copy it to graphite.wgsi WSGIScriptAlias / /opt/graphite/webapp/graphite.wsgi Alias /content/ /opt/graphite/webapp/content/ <Location "/content/"> SetHandler None </Location> # XXX In order for the django admin site media to work you Alias /media/ "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/django/contrib/admin/media/" <Location "/media/"> SetHandler None </Location> # The graphite.wsgi file has to be accessible by apache. <Directory "/opt/graphite/webapp/"> Options +ExecCGI Order deny,allow Allow from all </Directory> </VirtualHost>
你能帮我吗?
由于Apache 2.4, Require all granted是必需的:
<Directory /opt/graphite/conf> Require all granted </Directory>
至于Apache 2.2,你会写:
<Directory /opt/graphite/conf> Order deny,allow Allow from all </Directory>
请参阅升级笔记 。
请注意,您可以激活mod_access_compat以使用apache 2.4中的旧(2.4版本)指令。 如果你想快速排除这是你最初的问题的原因,可能是有用的,但坦率地说,迁移到Require是很容易的,没有必要使用这个模块来推迟它。
你错过了:
<Directory /opt/graphite/webapp> Order deny,allow Allow from all </Directory> <Directory /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/django/contrib/admin/media> Order deny,allow Allow from all </Directory>
你也不需要:
<Location "/content/"> SetHandler None </Location> <Location "/media/"> SetHandler None </Location>
这个“SetHandler None”的东西是旧的mod_python的东西,而不是mod_wsgi所需要的。
设置执行权限为我修复:
chmod u+x graphite.wsgi