I think I made some stupid mistake but I am not able to find it. Trying to run a simple python cgi script on apache webserver. My Code is
#/usr/bin/env python
import cgitb
import cgi
cgitb.enable()
print 'Content-Type: text/html'
print
print '<html>'
print '<head><title>My first Python CGI app</title></head>'
print ' <body>'
print ' <p>something to try<p>'
print ' </body>'
print '</html>'
this code was in /usr/lib/cgi-bin I tried to run it by localhost/cgi-bin/test.py but it shows 500 INTERNAL SERVER ERROR. I tried with changing its permissions,nothing happened. I am able to run html file from /var/www/html/file_name.html So I tried moving this in www/ and www/html/ (in both) with making cgi-bin folder and without it, nothing solved.
I had added this in apache2.conf
<Directory /usr/lib/cgi-bin>
Options +ExecCGI
AddHandler cgi-script .cgi .py
Order allow,deny
Allow from all
</Directory>
and var/log/apache2/error.log says
[Tue Jan 13 22:54:11.422641 2015] [cgid:error] [pid 10157:tid 140434248509184]
[client 127.0.0.1:44941] End of script output before headers: test.py
[Wed Jan 14 00:20:24.434351 2015] [cgid:error] [pid 26512:tid 140434573543296
(8)Exec format error: AH01241: exec of '/usr/lib/cgi-bin/test.py' failed
[Wed Jan 14 00:20:24.434778 2015] [cgid:error] [pid 10158:tid 140434456491776]
[client 127.0.0.1:45974] End of script output before headers: test.py