Is it possible to run apache with mod_wsgi and mod_php running together to serve python and php pages?
If so where can I find info on doing this?
Is it possible to run apache with mod_wsgi and mod_php running together to serve python and php pages?
If so where can I find info on doing this?
Yes you can mix then. See recipes towards end of section:
http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive
Specfically, the AddHandler/mod_rewrite/WSGI script fixup method.
This will allow a PHP site pages to take precedence with any URLs for which no PHP or static resources falling through to Python WSGI application.
The only thing I can think of is that a request can only be handled by one module or the other so you can't mix PHP and WSGI code. That means that if you use WSGIScriptAlias /myapp /some/where/app.wsgi
, http://example.com/myapp/foo.php will be processed by either mod_wsgi or mod_php, not both (most likely by mod_wsgi). This also means that your WSGI application can't be /
.
Theoretically, if you can get mod_php to work as an Apache Filter, your python app could output an appropriate PHP content-type header (application/x-httpd-php
) and PHP code and mod_php would process it, but I'm not sure if this can actually be done. I see a lot of stuff about mod_perl working this way, but it seems that you'll probably need to compile PHP using the apache2filter
SAPI instead of the default apache2handler, but searching for apache2filter turns up a lot of bug reports and other noise, but my Google-fu is too weak to find instructions on how to compile it, configure it or use it.
Otherwise, just set both up following their directions: mod_wsgi, mod_php5. If your distribution provides packages for apache, mod_php and mod_wsgi, use them and skip the compiling steps unless you really need to. If your distribution provides a2enmod
it should do most of the setup for you (at least the module-loading portion) but you'll need to set WSGIScriptAlias
yourself.