Solved

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

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
The viewer will learn how to count occurrences of each item in an array.

707 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

19 Experts available now in Live!

Get 1:1 Help Now