How does Apache bind multiple domain names in one site? Turn with Serveralias

Source: Internet
Author: User

APACHE2 How to bind multiple domain names in one site? With Serveralias
Used to be stupid, to make multiple domains point to the same site always write:

<virtualhost *:80>
ServerAdmin [email protected]
Documentroot/www/kuigg.com
ServerName kuigg.com
</VirtualHost>

<virtualhost *:80>
ServerAdmin [email protected]
Documentroot/www/kuigg.com
ServerName www.kuigg.com
</VirtualHost>

<virtualhost *:80>
ServerAdmin [email protected]
Documentroot/www/kuigg.com
ServerName abc.kuigg.com
</VirtualHost>

This is equal to how many domain names are tied and how many virtual hosts are open ...


Later read a book, found that there is a "serveralias" something to use
In fact, this can be:

<virtualhost *:80>
ServerAdmin [email protected]
Documentroot/www/kuigg.com
ServerName kuigg.com
Serveralias www.kuigg.com abc.kuigg.com
</VirtualHost>


How many domain names to tie can be written behind Serveralias, separated by a space

In a Linux server we usually put a number of sites, so we will be building a virtual directory. Sometimes a website
Also need to bind multiple domain names, then we configure virtual? Then I will share with you my configuration process.
XAMPP Management virtual directory files are:/opt/lampp/etc/httpd-vhosts.conf
[Email protected] extra]# VI httpd-vhosts.conf
<virtualhost *:80>
ServerAdmin[email protected]#管理服务器的邮箱 generally do not need to fill in
Documentroot/www/docs/dummy-host2.example.com #网站的目录
ServerName dummy-host2.example.com #需要绑定的域名
Serveralias www.example.com #绑定多个域名
DirectoryIndex example.php #设置默认的访问的页面
Errorlog Logs/dummy-host2.example.com-error_log #错误日志目录
</VirtualHost>
XAMPP does not have the ability to open the virtual directory by default
Need to modify/opt/lampp/etc/httpd.conf file
Search for the following code
# Include Etc/extra/httpd-vhosts.conf
Get rid of the front #
The configuration of the Apache server has been successfully restarted.

For example, to establish an IT information site, the site Directory is:/opt/lampp/htdocs/itinfo
Need to bind two domain names www.chinajquery.com www.jquerychina.com
Then our vhosts.conf add the following code to the last
<virtualhost *:80>
Documentroot/opt/lampp/htdocs/itinfo
ServerName www.chinajquery.com
Serveralias www.jquerychina.com
DirectoryIndex test.php
</VirtualHost>
Finally restart the Apache server
[[email protected] extra]/opt/lampp/lampp restart
Test the configuration of the virtual directory has not succeeded
Add to
192.168.139.129 www.chinajquery.com
192.168.139.129 www.jquerychina.com
To/etc/hosts
[[email protected] extra]/etc/init.d/networking restart restart NIC
The following interface is then shown in the browser input www.chinajquery.com to indicate the configuration success

How does Apache bind multiple domain names in one site? Turn with Serveralias

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.