小编qwe*_*boy的帖子

Python CGIHTTPServer崩溃与"OSError:[Errno 13] Permission denied"

我从我的主目录运行以下命令:

python -m CGIHTTPServer
Run Code Online (Sandbox Code Playgroud)

这运行服务器,但是当我尝试访问cgi-bin目录中的脚本时,我得到:

Traceback (most recent call last):
  File "/usr/lib/python2.7/CGIHTTPServer.py", line 251, in run_cgi
    os.execve(scriptfile, args, env)
OSError: [Errno 13] Permission denied
Run Code Online (Sandbox Code Playgroud)

以root身份运行并没有什么不同.这些文件似乎具有所有正确的权限:

student@bandersnatch:~$ ls -lhR
.:
total 12K
drwxr-xr-x 2 student student 4.0K Jun 13 18:38 cgi-bin
drwxr--r-- 2 student student 4.0K Jun 10  2004 kalpy
-rwxrwxrwx 1 student student 2.0K Jun 13 12:37 test.html

./cgi-bin:
total 8.0K
-rwxr-xr-x 1 student student 31 Jun 13 18:38 test.py
Run Code Online (Sandbox Code Playgroud)

编辑:test.py的内容是:

#!/usr/bin/python
print "test"
Run Code Online (Sandbox Code Playgroud)

shebang有效:

~$ which python
/usr/bin/python
Run Code Online (Sandbox Code Playgroud)

python linux cgi

8
推荐指数
1
解决办法
6883
查看次数

标签 统计

cgi ×1

linux ×1

python ×1