sqldump

(coffee) => code

Mod_python on Amazon Linux

It takes a few commands to get mod_python with Apache up and running on the free tier Amazon Linux AMI of EC2.

Step 1
Install Apache and mod_python using

1
yum install httpd mod_python

Step 2
Add python handlers by adding the following lines to /etc/httpd/conf.d/python.conf

1
2
3
4
5
6
7
8
9
10
11
LoadModule python_module modules/mod_python.so

<Directory "/var/www/html">
  Options Indexes FollowSymlinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
  AddHandler mod_python .py
  PythonHandler mod_python.publisher
  PythonDebug On
</Directory>

Step 3
Add a script to serve by creating a file /var/www/html/my.py and add the following code to it:

1
2
def index(req):
    return "Hello World!"

Access the file using http://my-ec2-address/my.py (make sure port 80 is open on the EC2-firewall)