macoswordpressapachemod-wsgimod-php

Getting mod_wsgi(reviewboard) and mod_php(wordpress) working on same servername but different path


I'm trying to get my wordpress site as well as my reviewboard site working under the same domain name.

Ex:

www.mysite.com (this is where i host my wordpress site)
www.mysite.com/reviewboard (this is where I want to host my reviewboard site)

I can get one or the other to work depending on my httpd-vhosts.conf file. However, I cannot get both to work(this is where I need your help!).

This is how I host my wordpress site:

<VirtualHost *:80>
    ServerAdmin myemail@gmail.com
    DocumentRoot "/opt/local/apache2/htdocs/mysite"
    ServerName www.mysite.com
    ErrorLog "/opt/local/apache2/logs/mysite.com-error_log"
    CustomLog "/opt/local/apache2/logs/mysite.com-access_log" common
</VirtualHost>

This is how I host my reviewboard site(which then breaks my wordpress site):

<VirtualHost *:80>
    ServerName www.mysite.com
    DocumentRoot "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs"

    # Error handlers
    ErrorDocument 500 /errordocs/500.html

    WSGIPassAuthorization On
    WSGIScriptAlias "/reviewboard" "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/reviewboard.wsgi/reviewboard"

    <Directory "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs">
        AllowOverride All
        Options -Indexes +FollowSymLinks
        Allow from all
    </Directory>

    # Alias static media requests to filesystem
    Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
    Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
    Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
    Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>

So, now I want to be able to figure out how to combine these somehow so I can have reviewboard hosted at the path specified above without breaking my wordpress site. I tried using the Alias command as mentioned here: http://stackoverflow.com/questions/1553165/multiple-django-sites-with-apache-mod-wsgi and here https://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines

However I can't get it to work. Here's my WIP. If you can be very specific as what I need to do in order to change this so it works that would be great since I'm new to this kind of stuff. Thanks!

<VirtualHost *:80>
    ServerName www.mysite.com
    DocumentRoot "/opt/local/apache2/htdocs/mysite"


    # Error handlers
    #hmm not sure where to put this since my document root is different??????
    #ErrorDocument 500 /errordocs/500.html

    WSGIPassAuthorization On
    Alias /reviewboard/ /opt/local/apache2/htdocs/mysite/reviewboard/htdocs/

    <Directory "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs">
        Options ExecCGI
        SetHandler wsgi-script  
        AllowOverride All
        Options -Indexes +FollowSymLinks
        Allow from all
    </Directory>

    # Alias static media requests to filesystem
    # Since I added the alias command above these are complaining about 
    #overlapping an earlier alias when I restart my apache server????
    Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
    Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
    Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
    Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>

Solution

  • Using a combination of what djc wrote and some of my tinkering here's the working version so that:

    www.mysite.com (wordpress site loads correctly)(mod_php)
    www.mysite.com/reviewboard (reviewboard site loads correctly)(mod_wsgi)
    

    Important make sure you clear your browser cache every time you restart your apache server as I kept falling into the trap of it showing incorrect data since I forgot to do that.

    Important2 Make sure the "/reviewboard" follows the "reviewboard.wsgi" to become "reviewboard.wsgi/reviewboard" otherwise it will not work and gives a 404 error!

    Here's the working version:

    <VirtualHost *:80>
        ServerAdmin myemail@gmail.com
        ServerName www.mysite.com
        DocumentRoot "/opt/local/apache2/htdocs/mysite"
        ErrorLog "/opt/local/apache2/logs/mysite-error_log"
        CustomLog "/opt/local/apache2/logs/mysite-access_log" common
    
        WSGIPassAuthorization On
        WSGIScriptAlias /reviewboard /opt/local/apache2/htdocs/mysite/reviewboard/htdocs/reviewboard.wsgi/reviewboard
        <Directory /opt/local/apache2/htdocs/mysite/reviewboard>
            Allow from all
            Options -Indexes +FollowSymLinks
            AllowOverride All
        </Directory>
    
        # Alias static media requests to filesystem
        Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
        Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
        Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
        Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
    </VirtualHost>