Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to run an instance of apache2 on an ubuntu server with two virtual hosts. One for redmine(phusion passenger), and one for ReviewBoard(mod_wsgi). I haven't created a single server configuration that will allow both of them to be available, and there are some curious things happening.

I am trying to get www.domain.com/redmine and www.domain.com/reviews. Depending on the initialization order of the two sites when I run sudo service apache2 restart depends on which site I am able to get to. For instance if I have in apache2.conf:

 Include sites-enabled/reviews
 Include sites-enabled/redmine

www.domain.com/reviews will be where I can get, but if they are reversed I can get to www.domain.com/redmine.

The configurations in sites-enabled look like:

#sites-enabled/redmine
<VirtualHost *:80>
   ServerName redmine.ts.com

   # !!! Be sure to point DocumentRoot to 'public'!
   DocumentRoot /var/www/tracking

   <Directory /var/www/tracking/redmine>
      Order allow,deny
      Allow from all
      Options -MultiViews FollowSymLinks Indexes
      PassengerResolveSymlinksInDocumentRoot on
      RailsBaseURI /redmine
   </Directory>
</VirtualHost> 

#sites-enabled/reviews
<VirtualHost *:80>
        ServerName reviews.ts.com
        DocumentRoot /var/www/reviews/htdocs

        # Error handlers
        ErrorDocument 500 /errordocs/500.html

        WSGIPassAuthorization On
        WSGIScriptAlias "/reviews" "/var/www/reviews/htdocs/reviewboard.wsgi/reviews"

        <Directory /var/www/reviews/htdocs>
                AllowOverride All
                Options -Indexes FollowSymLinks
                Allow from all
        </Directory>

        # Alias static media requests to filesystem
        Alias /reviews/media "/var/www/reviews/htdocs/media"
        Alias /reviews/errordocs "/var/www/reviews/htdocs/errordocs"
        Alias /reviews/favicon.ico "/var/www/reviews/htdocs/media/rbcommons/images/favicon.png"
</VirtualHost>

Does anyone know why these two sites are hosing the other dependent on which is initialized first? This is very frustrating

share|improve this question

1 Answer 1

You need to have a single virtual host with two directories under it to accomplish your goals. Two virtual hosts bound to *:80 with different ServerName settings will result in two separate named virtual hosts and the URLs will not be located under the one host.

This should be accomplished with the alias directive pointing to the directories you already have listed. Based on your two config files it should look roughly like the following.

<VirtualHost *:80>
   ServerName www.domain.com

   # Set a default root
   DocumentRoot /var/www/html

   # Define redmine subfolder and directory settings
   Alias /redmine /var/www/tracking/redmine
   <Directory /var/www/tracking/redmine>
      Order allow,deny
      Allow from all
      Options -MultiViews FollowSymLinks Indexes
      PassengerResolveSymlinksInDocumentRoot on
      RailsBaseURI /redmine
   </Directory>


   # These settings may need to be moved under the directory definiton
   WSGIPassAuthorization On

   WSGIScriptAlias "/reviews" "/var/www/reviews/htdocs/reviewboard.wsgi/reviews"
   <Directory /var/www/reviews/htdocs>
           AllowOverride All
            Options -Indexes FollowSymLinks
            Allow from all
   </Directory>
   Alias /reviews/media "/var/www/reviews/htdocs/media"
   Alias /reviews/errordocs "/var/www/reviews/htdocs/errordocs"
   Alias /reviews/favicon.ico "/var/www/reviews/htdocs/media/rbcommons/images/favicon.png"


</VirtualHost> 
share|improve this answer
    
ServerName is different for each VirtualHost and as long as that is the case you have multiple VirtualHost setups for port 80. This is the whole basis of how named based virtual hosts work. –  Graham Dumpleton Jul 29 '12 at 3:10
    
@GrahamDumpleton - I realize this, however he wants both entries to appear under a single named host within two directories. –  Tim Brigham Jul 29 '12 at 13:13
    
She*. You shouldn't always assume gender ;). Anywho, thank you. I did move them both into the same virtual host and with some tweaking got it to work. –  Adaleigh Martin Jul 29 '12 at 18:23
    
I have modified your answer then to correct the single statement I had issue with and which was not technically correct. My comment was to point out that the statement was incorrect and give you option of changing it which you didn't feel warranted. –  Graham Dumpleton Jul 29 '12 at 20:57

Your Answer

 
discard

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.