Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Two Sites On One Apache Server



4:07 pm on Sep 12, 2012 (gmt 0)

Hi all,

I have an apache server setup, and have two directories, both containing independent web sites (a live and development version of the same website).

I am redirecting to one web root on port 80, the other on port 8080 and this works fairly well, just sometimes my web browser will confuse me by loading files from the wrong site. Ie I will be testing changes in my development site, and I'll see content that I know is from the live site.

Below is the part of my http.conf that I'm using to control this.

Listen 80
Listen 8080

NameVirtualHost *:80
NameVirtualHost *:8080
<VirtualHost *:80>
ServerName Site1
DocumentRoot /opt/bitnami/apache2/htdocs/app/webroot/

<VirtualHost *:8080>
ServerName Site2
DocumentRoot /opt/bitnami/apache2/htdocs/dev/webroot/

Often no matter how many times I refresh for example, a page on the development site on port 8080, I will see content from the live site. If I explicity move the live site to a different path so that its definitely not there, only then will I get it to see content from the live site.

I only have 1 ip address on this web server so am unsure if my use of these "ServerName"s is right or wrong or if I can achieve what I'm doing at all. I don't know if firefox / chrome are smart enough to know that these are two different sites?

Any help getting this to be robust would be great.


6:43 pm on Sep 12, 2012 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

i'd do it like this:

<VirtualHost *:80>
DocumentRoot "/opt/bitnami/apache2/htdocs/app/webroot/"
ServerName example.com
ServerAlias www.example.com

<VirtualHost *:80>
DocumentRoot "/opt/bitnami/apache2/htdocs/dev/webroot/"
ServerName test.example.com

Featured Threads

Hot Threads This Week

Hot Threads This Month