Apache virtualhost Configuration

Source: Internet
Author: User

Edit httpd. conf, find include CONF/extra/httpd-vhosts.conf, and delete the annotator.

Edit the httpd-vhosts.conf and I installed wampserver on D:/Wamp, so the path here is D:/Wamp/bin/Apache/apache2.2.8/CONF/extra.
Clear the content and replace it with the following content:
Namevirtualhost *: 80

<Virtualhost *: 80>
Servername xxxxxxxxx.cn
Serveralias www.xxxxxxxxx.cn
DocumentRoot D:/www/WWW
</Virtualhost>

<Virtualhost *: 80>
Servername beta.gx.cn
Serveralias www.beta.gx.cn
DocumentRoot D:/www/beta.gx.cn/
</Virtualhost>

<Virtualhost *: 80>
Servername test.xxxxxxxxx.cn
Serveralias www.test.xxxxxxxxx.cn
DocumentRoot D:/www/test.xxxxxxxxx.cn/
</Virtualhost>
Description: The namevirtualhost *: 80 and the medium * are the current server IP address. If there is a fixed IP address, you can replace * with the IP address. Here I use a dynamic IP address, so I use *, when I read the Apache help documentation, I always thought that * is the corresponding domain name. This idea should be wrong, because I did not set the domain name when I filled it in. Set "servername" to the domain name and "DocumentRoot" to the root directory corresponding to the domain name on "servername.

At this time, the 403 permission error will occur when accessing the domain name. My D disk uses NTFS, And the permissions of the corresponding folder everyone are all controlled, so there is no system permission problem.

The problem lies in httpd. conf.

Edit httpd. conf, find the DocumentRoot "D:/www/" option. This is the default root directory path, but this is not the path to be changed. Keep searching and find <directory "D: /www ">, find the corresponding field, and add the following:
<Directory "D:/www/test.xxxxxxxxx.cn">
Options indexes followsymlinks
AllowOverride all
Order allow, deny
Allow from all
</Directory>

<Directory "D:/www/beta.gx.cn">
Options indexes followsymlinks
AllowOverride all
Order allow, deny
Allow from all
</Directory>
Here, "d:/www/beta.gx.cn" and "D:/www/test.xxxxxxxxx.cn" are the paths in the virtualhost.

Save httpd. conf and httpd-vhosts.conf, and then restart Apache.

Then access XXXXXXXXX. CN opens the D:/www/WWW directory, accesses beta.gx.cn D:/www/beta.gx.cn, and accesses test. XXXXXXXXX. CN is the D:/www/test.xxxxxxxxx.cn/directory, which shows the functions of Single IP multi-domain and multi-site.

========================================================== ====================

Your configuration is troublesome, difficult to manage, and insecure.
You can configure all
My configuration is as follows:

<Virtualhost *: 80>
<Directory "D:/workspace/drupal-5.10">
Options indexes followsymlinks
AllowOverride none
Order allow, deny
Allow from all
</Directory>
Serveradmin webmaster@dummy-host.localhost
DocumentRoot "D:/workspace/drupal-5.10"
Servername d5.chinahik.com
Serveralias www. dummy-host.localhost
Errorlog "log/dummy-host.localhost-error.log"
Customlog "logs/dummy-host.localhost-access.log" common
</Virtualhost>

<Virtualhost *: 80>
<Directory "D:/workspace/drupal-6.4">
Options indexes followsymlinks
AllowOverride none
Order allow, deny
Allow from all
</Directory>
Serveradmin webmaster@dummy-host2.localhost
DocumentRoot "D:/workspace/drupal-6.4"
Servername d6.chinahik.com
Errorlog "log/dummy-host2.localhost-error.log"
Customlog "logs/dummy-host2.localhost-access.log" common
</Virtualhost>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.