malformed header from script index.py Bad header
<p>I want to run python code in apache2(ubuntu 14.04) server. I have followed these steps and getting Error: </p>

<p>Step 1:</p>

<p>Configuration 1: I have created a directory and file under </p>

<pre><code>/var/www/cgi-bin
</code></pre>

<p>Configuration 2 : I have edited /etc/apache2/sites-available/000-default.conf</p>

<pre><code>Alias /cgi-bin /var/www/cgi-bin
&lt;Directory "/var/www/cgi-bin"&gt;
Options Indexes FollowSymLinks ExecCGI
AddHandler cgi-script .cgi .py
Allow from all
&lt;/Directory&gt;

&lt;Directory /var/www/cgi-bin&gt;
Options All
&lt;/Directory&gt;
</code></pre>

<p>Step 2:</p>

<p>and my python script is: index.py</p>

<pre><code>#!/usr/bin/env python
import cgi;
import cgitb;cgitb.enable()

print "Content-Type: text/plain\n"

print "&lt;b&gt;Hello python&lt;/b&gt;"
</code></pre>

<p>step 3:</p>

<p>When i ran through chrome browser using:
    URL : <a href="http://localhost/cgi-bin/index.py" rel="noreferrer">http://localhost/cgi-bin/index.py</a></p>

<p>step 4: </p>

<p>I am getting this Error in error-log</p>

<pre><code>malformed header from script 'index.py': Bad header: Hello Python
</code></pre>