Table of Contents
Howto for mod_python
Introduction
This tutorial shows you how to easily publish your PyAMF applications with the Apache 2 webserver and mod_python. Mod_python is an Apache module that embeds the Python interpreter within the server. This was tested with Python 2.4.3 and Ubuntu 6.06.1 LTS.
We're going to assume you already installed the Apache webserver running on 192.168.1.100. Flash applications will be able to access your PyAMF remoting gateway on http://192.168.1.100/flashservices/gateway.
Download WSGI gateway for mod_python
Create a folder for your application:
mkdir /var/www/myApp
Grab the WSGI gateway for mod_python and put it in your application folder:
wget http://www.aminus.net/browser/modpython_gateway.py?format=raw mv modpython_gateway.py?format=raw /var/www/myApp/wsgi.py
Create your PyAMF application
Make sure your Apache user (www-data) has access to your application files.
Create a startup file for your application in /var/www/myApp/startup.py:
from pyamf.remoting.gateway.wsgi import WSGIGateway def echo(data): return data application = WSGIGateway({'echo': echo})
Setup Apache vhost
This sample assumes you have a copy of the PyAMF source installed in /usr/src/pyamf but you can skip that step if you installed PyAMF in your Python's site-packages. Create a new vhost or modify an existing one:
<VirtualHost 192.168.1.100:80>
ServerName example.server.com
DocumentRoot /var/www/myApp
CustomLog /var/log/apache2/myApp-access.log combined
ErrorLog /var/log/apache2/myApp-error.log
LogLevel warn
ServerSignature Off
# PyAMF gateway
<Location /flashservices/gateway>
SetHandler mod_python
PythonPath "['/var/www/myApp', '/usr/src/pyamf']+sys.path"
PythonHandler wsgi
PythonOption wsgi.application startup::application
PythonOption SCRIPT_NAME /flashservices/gateway
# Only enable the options below when you're debugging the
# application. Turn them Off in a production environment.
PythonDebug On
PythonAutoReload On
</Location>
</VirtualHost>
Restart Apache
That's it! Your Flash/AMF clients will now be able to access your PyAMF application through http://192.168.1.100/flashservices/gateway.

