Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 29th, 2012, 09:26 AM
Northie's Avatar
Northie Northie is offline
Square Peg in a Round Hole
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Oct 2007
Location: North Yorkshire, UK
Posts: 3,440 Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 14 h 37 m
Reputation Power: 3896
.htaccess: multiple document roots based on IP

Hi,

we have a static IP to our office and a dedicated server for all our client's website (off site, at some secret location near slough).

Ideally I'd like to be able to client deploy test sites on the final domain/url and want to do something like this

Code:
if(client ip == our ip) {
     documentRoot = /path/to/dev/space
} else {
     documentRoot = /path/to/live/space
}


is this possible in .htaccess?

(yes, I'm using apache!)
__________________
PHP OOPS! <?php Output::Render(DB::Execute(SQL::makeFrom($_GET),$_GET)->fetchArray(),Template::getInstance('default')); ?>

PDO vs mysql_* functions: Find a Migration Guide Here

[ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]

Reply With Quote
  #2  
Old March 11th, 2012, 10:22 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,817 jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 4 Days 7 h 14 m 56 sec
Reputation Power: 1098
Let's see if I understand this correctly. You have two servers, one is your dev/preview server located in your office and one is your production server located in a data center. You'd like to have one Apache config that's shared across both servers but that uses a different DocumentRoot based on whether you're in the office or not

It sounds like your goal is to have your dev/preview as close to production as possible . If that's the goal, I don't think you're going to reach it with this approach because you'll need clientdomain.com to resolve differently, and that doesn't mimic production very well.

I believe the common approach is to use two DNS entries and two VirtualHosts, which results in two websites with two DocumentRoots. Set DNS so that clientdomain.com (and www.clientdomain.com) point to the production server while beta.clientdomain.com points to your dev server (office IP). Then create a VirtualHost for beta.clientdomain.com that has a DocumentRoot of /path/to/dev/space and one for clientdomain.com that has a DocumentRoot of /path/to/live/space. I believe order is important if you have a wildcard, catch-all ServerAlias, since *.clientdomain.com would match beta.clientdomain.com if it wasn't first.
Code:
NameVirtualHost *

<VirtualHost *>
  ServerName beta.clientdomain.com
  DocumentRoot /path/to/dev/space
  ...
</VirtualHost>

<VirtualHost *>
  ServerName clientdomain.com
  ServerAlias *.clientdomain.com
  DocumentRoot /path/to/prod/space
  ...
</VirtualHost>
Another approach is to use clientdomain.yourdomain.com.

You can then use this same config file on both dev and production. Note, however, that Apache will probably complain about missing DocumentRoots on startup.
__________________
# Jeremy

Explain your problem instead of asking how to do what you decided was the solution.

Reply With Quote
  #3  
Old March 12th, 2012, 04:15 AM
Northie's Avatar
Northie Northie is offline
Square Peg in a Round Hole
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Oct 2007
Location: North Yorkshire, UK
Posts: 3,440 Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 14 h 37 m
Reputation Power: 3896
Quote:
Let's see if I understand this correctly. You have two servers, one is your dev/preview server located in your office and one is your production server located in a data center. You'd like to have one Apache config that's shared across both servers but that uses a different DocumentRoot based on whether you're in the office or not


No, I'm a senior developer, I know how the web works, I'm not that stupid.

But you're right in some respects.

I develop locally for everything, and have two dedicated servers in the datacentre -stage and live.

However, this particular client has caused us to purchase propitiatory software paid for on a per-server licence cost. To keep the costs down I want to have stage and live for this client on the production server (where we've installed the software)

Being different servers, the IP of the stage and live servers are different, but if I put both on the live then the IP is the same.

Before we got the stage server we used to put stage and live on the same dedicated server and use sub domains, exactly in the way you describe (although it's all managed through plesk)

The problem for me now is that this obscure software the client requires reads the server name and bases business logic on that, so I as far as I can see I can't reliably test www.client.com on client.mycompany.com.

The other issue is that the client's old site is also hosted on the live server...............

............Just had a thought.....

I'll move client old site to stage and update DNS then in my hosts file override DNS to live for my testing, then switch DNS back again once new site is working

Last edited by Northie : March 12th, 2012 at 06:45 AM.

Reply With Quote
  #4  
Old March 14th, 2012, 09:27 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,817 jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 4 Days 7 h 14 m 56 sec
Reputation Power: 1098
Quote:
No, I'm a senior developer ...
Now how would I determine that from your post

You could probably do this with proxying, too, but a DNS approach would probably be faster and easier since it's just for testing.

Reply With Quote
  #5  
Old March 14th, 2012, 09:38 AM
Northie's Avatar
Northie Northie is offline
Square Peg in a Round Hole
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Oct 2007
Location: North Yorkshire, UK
Posts: 3,440 Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 14 h 37 m
Reputation Power: 3896
Quote:
Originally Posted by jharnois
Quote:
Originally Posted by me
No, I'm a senior developer ...

Now how would I determine that from your post


I didn't expect anyone too....but nor did i expect anyone to think I was trying to split a configuration over multiple server locations !!!

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > .htaccess: multiple document roots based on IP

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap