Solved

How to enable multi-domain sites hosted on the same appache?

Posted on 2012-04-08
2
313 Views
Last Modified: 2012-06-21
Now, I have one server, I want to host more and more websites on the same machine.
The server runs zend server ce (appache2)
Assuming three sites: www.a.com and www.b.com and www.c.com they will both runs on the server.
a.com will have the root directory of the appache;
b.com will have the htdocs/b/ directory, c.com will have the htdocs/c/ directory.
Who can tell me the detail configuration steps to implement that?

Thanks
0
Comment
Question by:matiascx
2 Comments
 
LVL 21

Accepted Solution

by:
Papertrip earned 500 total points
ID: 37821344
This is very common and is pretty straight forward.  For a basic vhost you only need to make a few changes.

Check out this page first http://httpd.apache.org/docs/2.0/vhosts/
If each website will have it's own IP then use IP-based virtual hosting, if they will share the same IP then use name-based.

The DocumentRoot option says where on the server the content will reside on the filesystem for any given vhost.

More info -- http://httpd.apache.org/docs/2.0/vhosts/examples.html

Name-based example:
# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com

# Other directives here

</VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example2.org

# Other directives here

</VirtualHost> 

Open in new window

0
 

Author Comment

by:matiascx
ID: 37826872
Hi, Papertrip,
Thanks to your information, I have succesfully solve the problem. But a new question:
Now, www.a.com ->htdocs/a/  , I have the requirement that: when the user enter www.a.com/root SHOULD be rooted to the htdocs/root  NOT the htdocs/a/root.   How can I implement that?

Thanks!
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I wrote this article to explain some important DNS concepts that should be known to avoid some typical configuration errors I often see in forums. I assume that what is described here is the typical behavior of Microsoft DNS client. I don't know …
Occasionally you run into the website or two that will not resolve properly using your own DNS servers.  Some people simply set up global forwarders for their DNS server.  I don’t recommend doing this because it can cause problems resolving addresse…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now