I want to run python code on apache2 server (ubuntu 14.04). I followed these steps and received an error message:
Step 1:
Configuration 1: I created a directory and a file under
/var/www/cgi-bin
Configuration 2: I edited / etc / apache 2 / sites-available / 000-default.conf
Alias /cgi-bin /var/www/cgi-bin
<Directory "/var/www/cgi-bin">
Options Indexes FollowSymLinks ExecCGI
AddHandler cgi-script .cgi .py
Allow from all
</Directory>
<Directory /var/www/cgi-bin>
Options All
</Directory>
Step 2:
and my python script: index.py
import cgi;
import cgitb;cgitb.enable()
print "Content-Type: text/plain\n"
print "<b>Hello python</b>"
Step 3:
When I launched the Chrome browser using: URL: http: //localhost/cgi-bin/index.py
step 4:
I get this error in the error log
malformed header from script 'index.py': Bad header: Hello Python
source
share