1

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 [email protected]
    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 [email protected]
    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 [email protected]
   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>

1 Answer 1

1

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.

2
  • 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, 2012 at 2:34
  • Get rid of the duplicate. What's the output from apache2ctl -S? Feb 19, 2012 at 8:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .