Solved

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

Posted on 2012-04-08
2
317 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

830 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