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 am new to configuring Apache. I have two applications that I need to run locally, they are running on different servers - one on jboss and the other on Jetty. Now both of them use the same Apache server for serving static files.

I resolved the issues with jboss and jetty server for http port (8080) and ajp port (8009). Both the servers startup without port conflicts. Then came the configuration part for Apache.

The httpd.conf has the definition for server1 (app1 on jboss), so I added a reference to a vhostsfile and put in the configuration for server2(app2 on jetty). Problem is if I have the reference to the vhostsfile, app2 works fine but app1 never gets resolved by Apache - "The requested URL /us/en_us was not found on this server"

At first I thought perhaps I should put both server's definition in vhosts file and so I did. Put in definition for server1 below server2 but - app1 still did not load while app2 loaded as before. Requests to app1 were showing up access logs for app2.

Then in the vhosts file, I swapped the definitions i.e put server1's definition above server2, now both the apps did not load in the browser.

I hope I am not too confusing here. App1 with server1's definition only (no vhost) works. Upon adding server2's definition (in vhosts), app1 stops working but app2 does work. Also, which ever server's definition is above the other in vhosts file was intercepting requests to both the apps.

NameVirtualHost *:80

    <VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.com
    DocumentRoot "C:/env/local/cust/httpd/docs/dummy-host.com"
    ServerName dummy-host.com
    ServerAlias www.dummy-host.com
    ErrorLog "logs/dummy-host.com-error.log"
    CustomLog "logs/dummy-host.com-access.log" common
</VirtualHost>

<VirtualHost app2.local.com:80>
    ServerAdmin app2@local.com
    DocumentRoot "C:/app2"
    ServerName app2.local.com
    ErrorLog "logs/store-error.log"
    CustomLog "logs/store-access.log" common    
    <Directory "C:/app2">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost app1.local.com:80>
   ServerAdmin app1@local.com
   DocumentRoot "C:/workspace/app1"
   ServerName app1.local.com
   ErrorLog "logs/app1-error.log"
   CustomLog "logs/app1-access.log" common

   <Directory "C:/app1/">
       Options Indexes FollowSymLinks
       AllowOverride all
       Order allow,deny
       Allow from all
   </Directory>
</VirtualHost>
share|improve this question
add comment

1 Answer

You're breaking name-based virtual hosting by having the hostnames in the <VirtualHost> definitions.

Change <VirtualHost app1.local.com:80> and <VirtualHost app2.local.com:80> to <VirtualHost *:80>, and make sure you have a NameVirtualHost *:80 somewhere in your config.

share|improve this answer
    
Yepp, I have 'NameVirtualHost *:80' in my vhosts file. And I changed to '; as you mentioned. It did not work however. App2 loaded and App1 did not. Access log for Server2 shows 404 for requests going to App1 - wrong wiring there. I want to mention that the httpd file also has the definition for server1 which we have repeated in vhosts file. –  SoltanG Feb 19 '12 at 2:34
    
Get rid of the duplicate. What's the output from apache2ctl -S? –  Shane Madden Feb 19 '12 at 8:52
add comment

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.