2016-05-19 23 views
2

ich unter Debian bin, installierte Python und lighttpd "apt-get install"Python-Skript nicht unter lighttpd Ausführung

Hier verwenden ist meine lighttpd conf-Datei:

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") 
} 

Ich habe diese Datei unter/var/www/html/cgi-bin/

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

hello.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>" 

Mein Problem ist, dass der Browser meine Datei nicht ausführt und meinen .py-Code anzeigt. Keine Fehler in der Datei /var/log/lighttpd/error.log Hat jemand eine Vorstellung davon, was schief läuft?

+0

Ich wünsche Web-Server eine bessere Dokumentation für derartige gemeinsame Aufgaben hatte. Viele Entwickler verwenden Python als Backend, aber es gibt wenig offizielle Dokumentation :( – www139

Antwort

2

Aus der Dokumentation hier:

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

es scheint, müssen Sie müssen auch cgi.assign einzustellen, z.B .:

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") 
+0

Großartig! Ich habe mein cgi conf in der lighttpd.conf entfernt und 10-cgi.conf aktiviert – kesdonc