Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering is it possible to run apache with mod_wsgi and mod_php running together to serve python and php pages?

If so were can I find info on doing this?


share|improve this question

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, 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.

share|improve this answer

Yes you can mix then. See recipes towards end of section:

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.