General discussion



By cpfeiffe ·
I have Apache running and serving a page for one application using its index.html file stored in /usr/lnms/html. I have another application that needs to serve a web page using another index.html file (I'll put it in /etc/apache). I'd like to use the same Apache server. I believe this can be done with virtual hosts.

I've added the following to the httpd.conf file:
NameVirtualHost X.X.X.X
<VirtualHost X.X.X.X>
DocumentRoot /etc/apache
ServerName www.ernie

I've alsoadded a cname record that points www.ernie to ernie. The original page should continue responding to ernie and the new page should respond to www.ernie. I tried replacing the cname record with an A record, but the result was the same. The DNS side returned the proper IP address in both cases.

When I go to either page ernie or www.ernie the browser appears to rotate between the two pages (watching the connect statement at the bottom of the browser) and ultimately settles on the last page.

I'd really like to do this without adding another IP address to the server. I can move around pretty good on Unix but I am new to Apache so please give details or examples of Apache syntax/setup.

I've already visited and man pages. I think I am close, but I am missing one or two important things. Any help is appreciated.


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -


by zeus_ru In reply to Apache

Ok here is your solution

you need to add to your httpd.conf

NameVirtualHost <> Where is your IP Address

And also you need to set every virtual server you want. For example

DocumentRoot /var/www/html/server1

Here is you IP Address
DocumentRoot is the path to the root of you server
Of course you need to have a DNS record to and pointing to your IP. In your case you need to set two Virtualserver.

NameVirtualHost <>
DocumentRoot /etc/apache
Servername www.ernie

DocumentRoot /usr/lnms/html
Servername ernie

You can test your virtual configuration running httpd -S

Dont forget to restart your apache server after you made your changes.

If you are using RedHat try /etc/init.d/httpd restart

Collapse -


by Shanghai Sam In reply to Apache

Thanks for the help. It looks like my syntax was just a little off.

Collapse -


by cpfeiffe In reply to Apache

This question was closed by the author

Related Discussions

Related Forums