File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Setting up 2 application using virtual host in apache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Setting up 2 application using virtual host in apache" Watch "Setting up 2 application using virtual host in apache" New topic
Author

Setting up 2 application using virtual host in apache

Nvvijay Rag
Greenhorn

Joined: Feb 04, 2011
Posts: 2

Hi,

I need to run 2 application in one webserver (apache), currently i am running one without any issues when i try to configure vhost (virtual host) to run my 2nd application it always defaults to first one or (what is mentioned under document root in httpd conf file) it does not pick from vhost conf file which has document root set for both application differently. Can some one send me sample of httpd & vhost config which as similar setup I need to use Ip based virtual host setting. I dont want to change my host file setup i need to set this up in my production system and i already registered the name in DNS for the host i am configuring.

Thanks,
Vijay
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Vijay and welcome to Javaranch! Can you post the conf files you've tried so far?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Nvvijay Rag
Greenhorn

Joined: Feb 04, 2011
Posts: 2
Hi,

below is my setup in both http & vhost conf file


Httpd.conf - setup

ServerRoot "C:\Apache2.2.17"

Listen 80

ProxyPreserveHost On

DocumentRoot "C:/Apache2.2.17/htdocs"

# Virtual hosts
Include conf/extra/httpd-vhosts.conf


My httpd-vhosts.conf -Setup

<VirtualHost 50.35.20.60>
DocumentRoot "C:/Apache2.2.17/htdocs"
ServerName www.website1.com
</VirtualHost>

<VirtualHost 50.35.20.65>
DocumentRoot "C:/Apache2.2.17/website2"
ServerName www.website2.com
</VirtualHost>


as per above configuration when I type www.website1.com , the home page(index.html) from htdocs should be served.
when I type www.website2.com home page (index.html) from website2 folder present under C:/Apache2.2.17/website2 should be displayed.
But index.html of website1 is always displayed even when I type www.website2.com

If I change the document root setup in httpd.conf to DocumentRoot "C:/Apache2.2.17/website2", when I type www,website1.com
I am getting website2.com hompe page

What is wrong in above configuration. My DNS configuration is done corerctly when i type www.website2.com
i can see IP as 50.35.20.65 in browser status bar, for website1.com i see 50.35.20.60.

Thanks


Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I'm not familiar with Apache Httpd set-up, but one thing I'd change is to make sure your '/' and '\' are consistent. Since you are not using spaces in your directory paths you should be able to use '\' safely. To also identify the root cause of the problem a little easier, I'd recommend having website one as separate from the default, e.g. Have:


Httpd.conf - setup



My httpd-vhosts.conf -Setup



This might help identify a problem where the DocumentRoot isn't being overridden as you'd expect.
 
wood burning stoves
 
subject: Setting up 2 application using virtual host in apache