首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Apache2 WSGI on Fedora上使用web2py获取403禁止错误

在Apache2 WSGI on Fedora上使用web2py获取403禁止错误
EN

Stack Overflow用户
提问于 2014-01-20 19:59:43
回答 2查看 2.2K关注 0票数 0

我得到了403禁止的网页显示:

代码语言:javascript
复制
Forbidden
You don't have permission to access / on this server.

访问日志显示与此对应的以下内容:

代码语言:javascript
复制
[Mon Jan 20 17:12:03.888576 2014] [authz_core:error] [pid 1940] [client XX.XX.XX.XX:32491] AH01630: client denied by server configuration: /opt/web-apps/web2py/wsgihandler.py

我为上述目录设置了以下权限:

代码语言:javascript
复制
       /]# ls -ld opt
drwxrwxrwx. 4 root root 4096 Jan 10 20:05 opt

     opt]# ls -ld web-apps
drwxrwxrwx 3 root root 4096 Jan 10 20:10 web-apps

web-apps]# ls -ld web2py
drwxr-xr-x 11 apache apache 4096 Jan 10 21:21 web2py

  web2py]# ls -l wsgihandler.py
drwxrwxr-x 1 apache apache 1128 Nov 28 19:23 wsgihandler.py

我的conf文件/etc/httpd/conf.d/default.conf如下:

代码语言:javascript
复制
NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
  WSGIDaemonProcess web2py user=apache group=apache processes=1 threads=1
  WSGIProcessGroup web2py
  WSGIScriptAlias / /opt/web-apps/web2py/wsgihandler.py
  WSGIPassAuthorization On

  <Directory /opt/web-apps/web2py>
    AllowOverride None
    Order Allow,Deny
    Deny from all
    <Files wsgihandler.py>
      Allow from all
    </Files>
  </Directory>

  AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) /opt/web-apps/web2py/applications/$1/static/$2

  <Directory /opt/web-apps/web2py/applications/*/static>
    Options -Indexes
    Order Allow,Deny
    Allow from all
  </Directory>

  <Location /admin>
    Deny from all
  </Location>

  <LocationMatch ^/([^/]+)/appadmin>
    Deny from all
  </LocationMatch>

  CustomLog /var/log/httpd/access_log common
  ErrorLog /var/log/httpd/error_log
</VirtualHost>

<VirtualHost *:443>
  SSLEngine on
  SSLCertificateFile /etc/httpd/ssl/self_signed.cert
  SSLCertificateKeyFile /etc/httpd/ssl/self_signed.key

  WSGIProcessGroup web2py
  WSGIScriptAlias /web2py /opt/web-apps/web2py/wsgihandler.py
  WSGIPassAuthorization On

  <Directory /opt/web-apps/web2py>
    AllowOverride None
    Order Allow,Deny
    Deny from all
    <Files wsgihandler.py>
       Allow from all
    </Files>
  </Directory>

  AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) /opt/web-apps/web2py/applications/$1/static/$2

  <Directory /opt/web-apps/web2py/applications/*/static>
    Options -Indexes
    ExpiresActive On
    ExpiresDefault "access plus 1 hour"
    Order Allow,Deny
    Allow from all
  </Directory>

  CustomLog /var/log/httpd/access_log common
  ErrorLog /var/log/httpd/error_log
</VirtualHost>
EN

回答 2

Stack Overflow用户

发布于 2014-01-22 19:11:38

试试这个:首先,如果您有linux用户apache和组apache,那么将您的web2py目录放入/home/ apache /,然后像这样更改您的apache sites available文件。希望这篇文章对你有帮助。

代码语言:javascript
复制
<VirtualHost *:80>
  ServerName example.com
  WSGIDaemonProcess web2py user=apache group=apache display-name=%{GROUP}
  WSGIProcessGroup web2py
  WSGIScriptAlias / /home/apache/web2py/wsgihandler.py

  <Directory /home/apache/web2py>
    AllowOverride None
    Order Allow,Deny
    Deny from all
    <Files wsgihandler.py>
      Allow from all
    </Files>
  </Directory>

  AliasMatch ^/([^/]+)/static/(.*) /users/apache/web2py/applications/$1/static/$2
  <Directory /users/apache/web2py/applications/*/static/>
    Order Allow,Deny
    Allow from all
  </Directory>
</VirtualHost>

如果您使用的是virtualenv,请检查您的wsgi文件,如下所示:

代码语言:javascript
复制
activate_this = '/path/to/virtualenv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this)
import sys
sys.path.insert(0, '/path/to/web2py_dir')
票数 0
EN

Stack Overflow用户

发布于 2014-08-21 19:54:02

这主要是因为您的apache2版本是2.4。您将需要升级您的conf文件。点击链接Upgrading apache2 to 2.4

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21233510

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档