Welcome to WebmasterWorld Guest from 54.167.83.224

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)

New User

joined:Sept 12, 2012
posts:1
votes: 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>

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


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 Sept 12, 2012 (gmt 0)

Senior Member

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

joined:Apr 19, 2002
posts:3171
votes: 8


i'd do it like this:

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

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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members