Forum Moderators: travelin cat

Message Too Old, No Replies

Developing Multiple Sites With Folders Treated As Roots

         

guiroo

4:37 am on Feb 6, 2004 (gmt 0)

10+ Year Member



Ok I'll start with my need before I try to sound technical.

I need to be able to develop multiple sites where I can use root paths for includes, global navigation etc. (Example: /assets/images/img.gif) I've already created subfolders under Library/WebServer/Documents.

I THINK this maybe called virtual hosting and have found articles but they all say "Open Pico and add a virual host." Sorry but I am not UNIX literate so if this is my solution I will need a bit more instruction than that. :)

So I need two or more folders where I can type in an IP and the IP is treated as the root in the URL. (http://127.0.0.2/assets/images/img.gif maybe?)

Can anyone help me?

Yidaki

10:32 am on Feb 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to have a look at the standard apache config file of your machine. Although using pico is not mac like, it's preytt easy.

Open a terminal window and type the following:

sudo pico /etc/httpd/httpd.conf

Then enter your admin password. Congrats - you just opened the apache config file using the simple text editor pico.

Scroll through the config file using the arrow keys. Pretty everything is well commented there so you should easily find the virtual hosting parts. You can also search in pico. Look at the help / shortcuts at the bottom of the pico terminal screen (the black bar).

The official apache docs about virtual hosting can be found here:
[httpd.apache.org...]

You might also want to have a look at some of the past discussions about virtual hosting on apache here at WebmasterWorld: Apache Virtual Host [google.com]

Especially this thread may be helpful for you:
Setting up Virtual Hosting on Mac [webmasterworld.com]


Important: make a copy of your httpd.conf file FIRST!

cp /etc/httpd/httpd.conf /httpd.conf

guiroo

5:07 pm on Feb 9, 2004 (gmt 0)

10+ Year Member



Hey thx for responding, I've read all those articles and they still assume alot. (I know I seem like an idiot but this is not my thing.)

I think I am missing something obvious — like I should be entering in an address where a * is or something. Let me try again by using my specific needs as an example so someone can reply with a specific example of code.

Note: This is only for local development purposes.

Ok I have Project1 and Project2 folder in /Library/WebServer/Documents/. I want to be able to type the ip 127.0.0.1 for Project 1 and I want to be able to type the ip 127.0.0.2 for Project2.

Or urls are fine too, like dev.project1.com and dev.project2.com.

Seems simple enough. :-D

P.S. I need this because the paths in the sites need to be root relative.

BjarneDM

11:16 pm on Feb 9, 2004 (gmt 0)

10+ Year Member



correct - you are looking for virtual hosting.
to keep it very, very simple without anything fancy like php, mysql, settings specific to a single server, etc this is what to do:

1) create a folder containing each of the sites
2) go to the bottom of /etc/httpd/httpd.conf, find "### Section 3: Virtual Hosts" and uncomment "#NameVirtualHost *:80".
3) a little further down you have a commented section between "#<VirtualHost *:80>" and "#</VirtualHost>". You'll need a copy of this section for each of your virtual websites in uncommented condition.
4) for each of your virtual websites you'll need to specify at least the "DocumentRoot" and "ServerName"
5) now you'll need to edit /etc/hosts: insert at line for each of your virtual websites at the end of this file - 127.0.0.1 ServerName
6) restart Apache

the easiest way to edit these two files is if you've got bbedit 7.* installed. it comes with a commandline tool so you can just enter 'bbedit /etc/httpd/httpd.conf' in the terminal.

aus_dave

9:38 pm on Feb 25, 2004 (gmt 0)

10+ Year Member



guiroo, not sure if you are still looking for a solution but there is a script available that will make the job a lot easier for you:

[patrickgibson.com...]

timster

8:57 pm on Feb 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm all for doing things the free, hard way, but for those who aren't, it looks like Mac OS X server lets you do Virutal Hosts in GUI.

guiroo, which do you hate more -- Unix headaches or spending $500?

[apple.com...]

There's also WebStar -- they're still around and promising to make everything easy for $300.

[4d.com...]

aus_dave

1:32 pm on Feb 27, 2004 (gmt 0)

10+ Year Member



timster, I think guiroo was referring to plain old OSX, not OSX Server?

I put virtual hosting in the 'too hard' basket until I came across that script - now each of my projects has its own virtual host and document root, which makes things easy :).