【问题标题】:Python CGIHTTPServer access denied on OS X在 OS X 上拒绝 Python CGIHTTPServer 访问
【发布时间】:2013-04-13 18:59:35
【问题描述】:

我在尝试从浏览器触发 CGI 中的 Python 脚本时收到此错误;

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/CGIHTTPServer.py", line 251, in run_cgi
    os.execve(scriptfile, args, env)
OSError: [Errno 13] Permission denied
1.0.0.127.in-addr.arpa - - [20/Apr/2013 14:51:16] CGI script exit status 0x7f00

我没有以 root ($ python-32 main.py) 身份运行主进程。

This topic 似乎不适合我。

使脚本可执行也不起作用($ chmod +x index.py-rwxr-xr-x)。

【问题讨论】:

    标签: python-2.7 permissions osx-mountain-lion cgihttpserver


    【解决方案1】:

    终于搞定了。这是基本脚本;

    index.py

    #!/usr/bin/env python
    import cgi
    print 'Content-Type: text/html\n\n'
    print ''
    print 'test'
    

    要求

    • 文件需要可执行; $ chmod +x index.py
    • 文件需要有#!/usr/bin/env python

    希望它对将来的人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-22
      • 2013-12-31
      • 2012-06-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多