gpt4 book ai didi

python 脚本不在 lighttpd 下执行

转载 作者:太空宇宙 更新时间:2023-11-04 03:13:06 25 4
gpt4 key购买 nike

我在 Debian 下,使用“apt-get install”安装 python 和 lighttpd

这是我的 lighttpd 配置文件:

server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_rewrite",
"mod_cgi"
)

server.document-root = "/var/www/html"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80


index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/$

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

# configuration cgi-python
$HTTP["url"] =~ "^cgi-bin/" {
cgi.assign = ( ".py" => "/usr/bin/python" )
}

我在/var/www/html/cgi-bin/下有这个文件

-rwxr-xr-x 1 www-data www-data  245 mai   19 12:09 hello.py

你好.py:

#! /usr/bin/python
#
print "Content-Type: text/html\n\n"
print '<html><head><meta content="text/html; charset=UTF-8" />'
print '<title>Rapsberry Pi</title><p>'
for count in range(1,100):
print 'Hello&nbsp;World...'
print "</p></body></html>"

我的问题是浏览器不执行我的文件并显示我的 .py 代码。/var/log/lighttpd/error.log 中没有错误任何人都知道出了什么问题?

最佳答案

来自这里的文档:

https://wiki.archlinux.org/index.php/lighttpd#CGI

看来您还需要设置cgi.assign,例如:

cgi.assign                 = ( ".pl"  => "/usr/bin/perl",
".cgi" => "/usr/bin/perl",
".rb" => "/usr/bin/ruby",
".erb" => "/usr/bin/eruby",
".py" => "/usr/bin/python",
".php" => "/usr/bin/php-cgi" )

关于python 脚本不在 lighttpd 下执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37323256/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com