Following steps can be performed to get python scripts executed in Apache(CGI Approach).This was tested in Ubuntu 12.04 and python 2.7.
1.If you already have apache and python installed in your system, you need to enable cgi in apache(you need to install apache in order to perform following steps)
sudo a2enmod cgi
2. To enable python scripts to be executed in sites path, modify apache configuration as below.
<Directory /var/www/mysite/public_html/cgi-bin>
Options ExecCGI
SetHandler cgi-script
</Directory>
3. To enable .py files to be executed as scripts in particular folder, make make change as below
<Directory /srv/www/yoursite/public_html>
Options +ExecCGI
AddHandler cgi-script .py
</Directory>
4. In order to display the data in html format in web. add following line at the top of your python script
#!/usr/bin/env python>
print "Content-type: text/html\n\n"</strong