PDA

View Full Version : Local development of site without constant update of hosts


Kelon
09-05-2009, 12:05 AM
Hi
I'm running Apache 1.3 on OSx 10.4. I'd like a nice simple way of configuring Apache so I can....

Duplicate a site (in my web dev space) -> rename the duplicate folder to say: "v4siteA"
Without touching hosts or conf.. go immediately type in a browser: http://v4siteA.myDevSpace/ and bingo... all there, root relative, brill.

If http://myDevSpace/ is already all set up in hosts and conf., then what simple (that word again) ways of going about this are there?

I've been faffing-on trying to use DocumentRoot /myDevSpace/%1/htdocs somehow and just not 'getting-it' somewhere. I'm really struggling, the tech docs out there seem to have passed over my head, must be in dim mode.

All pointers welcome. Thank you for stopping by.

clunk.werclick
09-08-2009, 09:21 PM
I'm probably not going to be that much help to you as I'm running Apache2 on Linux - however, as there are not replies I'll tell you what I know, in case it helps you out.

First of all you need to clarify your understanding of the url you've posted;
http://v4siteA.myDevSpace/

This would usually be http://<subdomain_or_host>.<domain>.<tld>
So what you are trying to do is set up a separate sub domain off 'myDevSpace' but on the same host? I suspect this is probably not quite what you want to do on a local development machine ?

If it's a quick 'clone' of a site you want, without touching the conf, you'd have to do it the other way round and create subdirectories off of myDevSpace. Like this;

myDevSpace/v4siteA
myDevSpace/v4siteB

You would then simply clone the contents of myDevSpace/v4siteA to myDevSpace/v4siteB. Job jobbed. However, this is less than ideal but may be just fine for development provided you don't start using absolute URL's.

It's probably better to set up virual hosts with Apache so you can call each as a separate site;

http://site1
http://site2

This does mean adding a virtual host with Apache (It's relatively painless in Apache2, and AFAIR it's not difficult in older versions). Apache would then listen on 80 for host header site1 or site2 and send the request to the required virtual site. The relative Apache virtual host conf will serve the request from the correct parent directory. From an admin point of view this would be copy directory structure to new home, set up new virtual host to point to this, restart / reload Apache. Job's a goodun'

One extra step for local development machines. Add an entry in your hosts file to catch requests for http://site1 and http://site2 and loop them back to the host running Apache (probably 127.0.0.1 in this case).

Once you've sussed it once, it becomes a quick yank 'n' paste job to set up another.

My apologies if I've got the wrong end of the stick to what you want to do.

eak
09-08-2009, 09:23 PM
Try reading this page:
http://httpd.apache.org/docs/1.3/vhosts/mass.html

Kelon
09-08-2009, 09:46 PM
Hi both of you. Thank you for posting a response, I appreciate it.

Clunk... thank you., I already do what you suggest "quick clone" and I know it's not much work to alter the conf or hosts.. I almost do it in my sleep. I'd rather not however.

Eak... I've been there ...oooooh, I've for some reason missed "most easily using mod_vhost_alias, but if you are using a version of Apache up to 1.3.6 then you must use mod_rewrite." (My emphasis). I'm 1.3.4 ..... joy... mod_rewrite... never been comfy with that. Ah well, into the breech....

Thank you both.. taking the time to respond is appreciated.. helped me 'look again', sometimes all that is needed.

Kelon
09-11-2009, 09:19 PM
Just a follow-up.. I've messed about with mod_rewrite... copying in and amending the example in the techdocs.. all to no avail. I've never had much luck with mod_rewrite.. one of those things I'm going to have to methodically work through in order for my brain to get... odd, php, ActionScript., no probs... mod_rewrite... weird....so.. think I'm beggared till I can go to Apache2.. joy.