简体   繁体   中英

Apache2 mod_wsgi 403 forbidden error

I had it configured right, but then I decided to reinstall my Debian (switching from wheezy to jessie version by the way). Here's the problem:

I have a python mod_wsgi application at: /mnt/doc/Python/www/index.py .

$ ls -l / | grep mnt
drwxr-xr-x   3 root root  4096 sty 12 09:36 mnt

$ ls -l /mnt
drwxrwxrwx 1 sven sven 20480 sty  7 19:34 doc

$ ls -l /mnt/doc/Python/www/
total 12
drwxrwxrwx 1 sven sven 4096 Jan  3 19:52 core
-rwxrwxrwx 1 sven sven    0 Dec 22 13:25 __init__.py
drwxrwxrwx 1 sven sven    0 Dec 24 00:11 silva
-rwxrwxrwx 1 sven sven  984 Dec 22 13:47 silva.py
-rwxrwxrwx 1 sven sven  697 Dec 25 13:32 txt

All subdirectories have the same permissions as /mnt/doc , but still I get 403 Forbidden error, when trying to open the site. It's configuration below:

WSGIScriptAlias /huh /mnt/doc/Python/www/index.py                 
<Directory /mnt/doc/Python/www>                                   
    Order allow,deny                                                            
    Allow from all                                                              
</Directory>

When trying to open the page, the following message appears in Apache2 log:

[authz_core:error] [pid 15269:tid 140518201730816] [client ::1:44130] AH01630: client denied by server configuration: /mnt/doc/Python/www/index.py

I'm pretty sure that I copied previous configuration quite exactly. Did anything change recently?

EDIT: I neglected to add that I use Python 3.3 and libapache2-mod-wsgi-py3 Debian package.

I solved it finally. pxl was half-right, because not only Allow from all should be replaced by Require all granted , but also Order allow,deny is no longer necessary. It turns out to be the reason for my error. Complete script alias config should be like this:

WSGIScriptAlias /huh /mnt/doc/Python/www/index.py                 
<Directory /mnt/doc/Python/www>                                   
    Require all granted
</Directory>

And it works.

Replace Allow from all with Require all granted .

Reference for Apache module mod_authz_core

I wrote like below,

    WSGIScriptAlias /hello /home/myself/projects/hello/hello.wsgi
    <Directory /home/myself/projects/hello>
    Order allow,deny
    Allow from all
    Require all granted
    </Directory>

and it works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM