I can not run the cgi script on the server ..

 #!/bin/env python3 print("Content-type: text/html;charset=utf-8") print() print("<h1>Hello world!</h1>") 

ls:

  root@server:/var/www# ls -l cgi-bin -rwxrwxrwx 1 www-data www-data 107 окт 19 17:58 1.py 

log:

 Serving HTTP on 0.0.0.0 port 8000 ... 770.70.802.360 - - [19/Oct/2016 18:38:26] code 403, message CGI script is not a plain file ('/cgi-bin/') 770.70.802.360 - - [19/Oct/2016 18:38:26] "GET /cgi-bin/ HTTP/1.1" 403 - 770.70.802.360 - - [19/Oct/2016 18:38:37] "GET /cgi-bin/1.py HTTP/1.1" 200 - Traceback (most recent call last): File "/usr/lib/python3.5/http/server.py", line 1135, in run_cgi os.execve(scriptfile, args, env) PermissionError: [Errno 13] Permission denied: '/var/www/cgi-bin/1.py' 77.87.102.36 - - [19/Oct/2016 18:38:37] CGI script exit status 0x7f00 

server run like this:

 python3 -m http.server --cgi 

when trying to open a file through a browser, it offers to download this file ..

rights are everywhere 777 .. the www-data group is also everywhere ... what could it be? why Permission denied ?

  • one
    Do you have /bin/env ? A better way is to specify /usr/bin/python3 . Try explicitly as a www-data user to execute the sudo -u www-data /var/www/cgi-bin/1.py script sudo -u www-data /var/www/cgi-bin/1.py - jfs

1 answer 1

Check the rights not only on the file, but also on the directories above the tree. Enough "x" on the directories so that the user can get to the file and "r" on the file itself so that it can open it.