我正在尝试在我的 Mac OS X 10.7 lion 上设置 graphite,我已经设置 apache 通过 WSGI 调用 python graphite 脚本,但是当我尝试访问它时,我得到了来自 apache 的禁止信息,并在错误日志中出现了这个信息。
"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>
你能帮我吗?
答案1
从 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 之前)指令。如果您想快速排除这是导致初始问题的原因,这可能会很有用,但坦率地说,迁移到 2.4Require
很容易,没有必要使用此模块只是为了推迟它。
答案2
答案3
您缺少:
<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 不需要它。
答案4
设置执行权限为我修复了这个问题:
chmod u+x graphite.wsgi