Hello world .cgi

Alles, was den Apache betrifft, kann hier besprochen werden.

Hello world .cgi

Postby handeglo » 29. May 2007 15:14

Hallo leute ....

hab hier ein ganz einfaches .cgi script und rufe es mit python programmiert :-)

Code: Select all

#!/usr/bin/python
print "Hallo Welt"



naja wenn ich es über die konsole aufrufe gibt es mir schon Hallo Welt aus
aber über den Browser nur den Fehlermeldung Internal Server Error 500.
Die rechte der datei sind auf 755 ja auch mit 777 probiert worden.
handeglo
 
Posts: 4
Joined: 23. May 2007 10:02

Postby Wiedmann » 29. May 2007 16:34

aber über den Browser nur den Fehlermeldung Internal Server Error 500.

Dazu gibt es immer weitere Infos im error_log.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby MisterWing » 18. October 2007 15:03

Hallo,

bin auf deine Anfrage gestossen.
Falls irgendwer mal wieder diesen thread aufrufen sollte, so hab ich hier die Lösung.

Folgendes kommt in die httpd.conf

Code: Select all
//cgi benutzen
LoadModule cgi_module modules/mod_cgi.so

//ähnlich wie index.html wird index.py automatisch aufgerufen
<IfModule dir_module>

        DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl
                               index.html index.htm index.shtml index.phtml
                               index.py

</IfModule>


//*.py statt *.cgi im Browser aufrufen
<IfModule mime_module>

         AddHandler cgi-script .py

</IfModule>




In deine Python-Datei sollte dann noch das cgi import werden.
Code: Select all
#!/usr/bin/python
import cgitb; cgitb.enable()
import cgi

print "Hallo Welt"
MisterWing
 
Posts: 12
Joined: 27. April 2007 15:07


Return to Apache

Who is online

Users browsing this forum: No registered users and 16 guests