General discussion

Locked

Apache

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
</VirtualHost>

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 www.apache.org/docs and man pages. I think I am close, but I am missing one or two important things. Any help is appreciated.

Thanks.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Apache

by zeus_ru In reply to Apache

Ok here is your solution

you need to add to your httpd.conf

NameVirtualHost <11.22.33.44> Where 11.22.33.44 is your IP Address

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

<VirtualHost 11.22.33.44>
DocumentRoot /var/www/html/server1
Servername server1.com
</Virtualhost>

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

NameVirtualHost <11.22.33.44>
<VirtualHost 11.22.33.44>
DocumentRoot /etc/apache
Servername www.ernie
</Virtualhost>

<VirtualHost 11.22.33.44>
DocumentRoot /usr/lnms/html
Servername ernie
</Virtualhost>


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 -

Apache

by Shanghai Sam In reply to Apache

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

Collapse -

Apache

by cpfeiffe In reply to Apache

This question was closed by the author

Related Discussions

Related Forums