I have been trying to run a simple python script hello.py
with CGI but am getting 500 Internal Server Error.
My python code.
#!/usr/bin/python2.7
print '<html>'
print '<head>'
print '<title>Hello World - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello World! This is my first CGI program</h2>'
print '</body>'
print '</html>'
The directory which i have the python script running is in /var/www/crunchworld
.The conf file which i enabled is in `/etc/apache2/conf-available/crunchworld.conf
The conf file looks like
<Directory /var/www/crunchworld>
Options +ExecCGI
AddHandler cgi-script .cgi
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
I have cgi enabled and given the necessary permission for the file hello.py but its still showing me internal server error.When i checked the logs i see
End of script output before headers: hello.py
I have researched about the error and give appropriate permissions for the file but it doesnt work.
Any help would be so much appreciated. Thanks in advance.
Further changes i have made.
- I have added
AddHandler cgi-script .cgi .py
in my crunchworld.conf file.
2.I have given permission for the file hello.py
- I have symlinked
/etc/apache2/conf-available/crunchworld.conf
in/etc/apache2/conf-enabled
4.I had already installed python2.7 on the path /usr/bin/python2.7
and i have also tried using #!/usr/bin/env python
but still it doesnt work.
Upon checking the logs i found End of script output before headers: hello.py, referer: http://localhost/
Thank you for your recommendations but it is still showing 500 internal error.