title: How do I run python cgi script on apache2 server on Ubuntu 16.04?
body: <p>I am a newbie so I saw some tutorials.
  I have a python script as <strong>first.py</strong></p>
  
  <p><code>#!/usr/bin/python3
  print "Content-type: text/html\n"
  print "Hello, world!"</code></p>
  
  <p>I have multiple versions of python on my computer.
  I couldn't figure out my cgi enabled directory so I pasted this code at three places</p>
  
  <ol>
  <li><p>/usr/lib/cgi-bin/first.py </p></li>
  <li><p>/usr/lib/cups/cgi-bin/first.py   </p></li>
  <li><p>/var/www/html/first.py</p></li>
  </ol>
  
  <p>Now when I run this code in terminal it works fine but when I type</p>
  
  <p><code>curl http://localhost/first.py</code></p>
  
  <p>it spit out just simple text and does not execute.</p>
  
  <p>I have given all the permissions to first.py</p>
  
  <p>I have enabled and started the server by commands</p>
  
  <p><code>a2enmod cgi 
  systemctl restart apache2</code></p>
  
  <p>Please tell how do I execute and what is going on here?
  Thanks in advance.</p>