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 January 30th, 2012, 04:46 AM
bacterozoid bacterozoid is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2009
Posts: 95 bacterozoid User rank is Sergeant Major (2000 - 5000 Reputation Level)bacterozoid User rank is Sergeant Major (2000 - 5000 Reputation Level)bacterozoid User rank is Sergeant Major (2000 - 5000 Reputation Level)bacterozoid User rank is Sergeant Major (2000 - 5000 Reputation Level)bacterozoid User rank is Sergeant Major (2000 - 5000 Reputation Level)bacterozoid User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 9 h 45 m 30 sec
Reputation Power: 29
Different document root per subdomain

I used to be on shared hosting with cPanel. I had multiple subdomains that all pointed to different locations:

a.domain.com -> /www/versions/2
b.domain.com -> /www/versions/3
c.domain.com -> /www/versions/3
d.domain.com -> /www/versions/1

I did this by using cPanel to create the subdomain every time, then set the document root for each of them. That worked fine...using different document roots let me easily include files without worrying about which version to include them from.

I could do this:

PHP Code:
include file.php 

instead of this:

PHP Code:
include $_SERVER['document_root'] . '/www/versions/' $version '/file.php'

Now I've moved over to a VPS and want to do this right. Individually setting up subdomains is slow, so I intend to use a wildcard so that all subdomains point to my server. I don't think I can set different document roots this way, though. I have an entry in the database for each sudomain with a column for version...what's the best way to set this up?

I'm thinking that I hit the database to check the version, then do something like this, but I'm not confident it's the right way:

PHP Code:
 define('CLIENT_DOCUMENT_ROOT'$_SERVER['document_root'] . '/www/versions/' $version); 


This all has to be done automatically. I can't edit the http.conf and restart Apache every time a new subdomain is added.

Any thoughts?

Reply With Quote
  #2  
Old March 11th, 2012, 11:33 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
If you don't want to restart Apache every time you need a new version, then I'd recommend staying away from having Apache do this for you. If you did want to use Apache, you could use mod_rewrite to set an environment variable based on the domain, and you should be able to do this in .htaccess.

Although a simple PHP array that matches host to version would probably be easiest (and prevent a database query):
PHP Code:
 $versions = array(
  
'a.domain.com' => 2,
  
'b.domain.com' => 3
);

$version $versions[$_SERVER['HTTP_HOST']]; 
__________________
# Jeremy

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

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > Different document root per subdomain

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