Apache configuration Multi-Virtual site method

Source: Internet
Author: User

This configuration process is simple,

Like your mainframe ip:666.555.444.333.

Three sites, the domain name is: www.aaa.com,www.bbb.com,www.ccc.com

The corresponding web site files are placed under the root directory of the site:/WWWROOT/AAA;/WWWROOT/BBB;/WWWROOT/CCC folder

Note: Under Windows for ', Linux '/', this article is written under Linux.

Open the Apache profile httpd.conf file and set different domain names to different virtual directories:

The code is as follows Copy Code

Listen 80//Default listener port

Namevirtualhost 666.555.444.333


<virtualhost 666.555.444.333:80>

DocumentRoot "/VAR/WWWROOT/AAA"

ServerName www.aaa.com

DirectoryIndex index.php

</Virtualhost>


<virtualhost 666.555.444.333:80>

DocumentRoot "/VAR/WWWROOT/BBB"

ServerName www.bbb.com

DirectoryIndex index.php

</Virtualhost>

Another way is not to write in the httpd.conf file,
We need to open the httpd.conf first and find

The code is as follows Copy Code
#Include conf/extra/httpd-vhosts.conf

# up front #


and then open

The code is as follows Copy Code
Confextrahttpd-vhosts.conf

Open in front and add a sentence

The code is as follows Copy Code

Namevirtualhost 127.0.0.1:80 your IP address.

And then write it down here.

The code is as follows Copy Code

<virtualhost 127.0.0.1>
DocumentRoot "e:/aaa/phpmyadmin/"
ServerName www.111cn.net
</VirtualHost>

<virtualhost 127.0.0.1>
DocumentRoot "e:/aaa/phpmyadmin/"
ServerName www.111cn.net
</VirtualHost>

The last save reboot is KO.

And in this test

  code is as follows copy code

< VirtualHost 192.168.1.3:77>  
    documentroot "e:/www/sfds/"
     ServerName 127.0.0.1
</virtualhost>

<virtualhost 192.168.1.3:9>  
     documentroot "e:/www/android/upfile/soft/"
    ServerName 127.0.0.1
</ Virtualhost>

<virtualhost 192.168.1.3:8>  
    documentroot e:/www/ android/upfile/img/
    ServerName 127.0.0.1
</virtualhost>

With ports, if the opening port is increased only in front of the httpd.conf


Listen 88
Listen 18
Listen 999
Listen 888
Listen 8888
Listen 8
Listen 9
Listen 58
Listen 66
Listen 77
Listen 69

So you can operate with ports.

Original articles reproduced in this site annotated source http://www.111cn.net/sys/index.html

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.