Deploying CherryPy (or other Python web) Applications
I have been thinking lately about how it is still pretty involved to deploy a CherryPy (or any Python web) application to a “production” server (Apache, lighttpd, IIS, etc).
The easiest method that I know at this point is mod_proxy with Apache:
<Virtualhost *>
ServerName cpsite.server.domain
CustomLog "/var/log/apache/cpsite/access_log" combined
ErrorLog /var/log/apache/cpsite/error_log
ProxyPass / http://localhost:8081/
ProxyPassReverse / http://localhost:8081/
</Virtualhost>
As long as the “cpsite” app is running on port 8081, everything should be cool.
If you are running Apache 2, you can even do this (grabbed from the CP wiki):
<Location /myapp>
ProxyPass http://localhost:8080
ProxyPassReverse http://localhost:8080
RequestHeader set CP-Location /myapp
</Location>
If you want to do WSGI, it starts getting quite a bit more complicated. You need FCGI or SCGI or mod_python support for Apache and a handful of other Python libraries/modules to glue your (CP) WSGI app to the production server.
Are there any other easier ways that I am missing?
One thing that I like about the way PHP works is how easy it is to deploy apps. It usually works like this.
1. Stick app’s folder somewhere in your document root
2. Modify the app’s config.php file
3. (maybe) Browse to http://theserver/theapp/install.php and follow the steps
That’s pretty simple. *sigh*
Dreaming of mod_wsgi,
cw
February 9th, 2006 at 12:02 pm
I just made modpython_gateway standalone last night; that is, you no longer need to download wsgiref. One step closer to deployment nirvana!
February 9th, 2006 at 1:00 pm
That’s great news! Since wsgiref was not only another package but only available in svn, that added another barrier to deployment. If only mod_python was more widespread
February 10th, 2006 at 6:06 am
The mod_wsgi idea is sensible mate and I wonder how tough it would be to make one.
Good work!
February 10th, 2006 at 6:26 am
I think it would make most sense to integrate it with mod_python. But actually doing that is a bit beyond my programming ability, I think. I did download the mod_python source to check it out yesterday, but even understanding what does what is going to take a while.
Lighttpd has a nice, fairly well documented plugin system that might be an easier target. But then there is the whole issue of having to basically redo mod_python for Lighty plus adding WSGI. Hhhhmmm…