homepage Welcome to WebmasterWorld Guest from 54.227.34.0
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Two Sites On One Apache Server
mark007



 
Msg#: 4494366 posted 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>

<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.

 

topr8

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



 
Msg#: 4494366 posted 6:43 pm on Sep 12, 2012 (gmt 0)

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>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved