python -m CGIHTTPServer
这个命令运行了服务器,但是当我尝试访问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
以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
编辑:test.py的内容如下:
#!/usr/bin/python
print "test"
这个shebang是有效的:
~$ which python
/usr/bin/python
test.py
中看到_shebang_行会很有用。如果定义的解释器不是有效的可执行文件,可能会出现该错误。 - rodrigo