Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can i gnupg encrypt a PDF document? 12 33
PHP PDO   How do I correctly remove record using DELETE FROM? 1 21
Decrypt string by php 7 31
DNS propagation 5 21
This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

810 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