Apache Configuring multi-site Access "Assigning a two-level domain name to a project"

Source: Internet
Author: User
Tags domain name definition

First-level domain name (baidu.com) also known as the top-level domain name, register the first-class domain name is to pay

The level two domain name (image.baidu.com) is based on the extension of the first-level domain name, so long as you buy a domain name, level two domain name can be arbitrarily configured

In fact (www.baidu.com) is also a two-level domain name, but everyone has been accustomed to use the WWW prefix of the two-level domain name as the site's main domain entry

With DNS resolution providers, you can bind different host IPs for each level two domain name so that you can set up multiple sites even if there is only one primary domain name.

If you have only one host, and you want to build multiple projects on it, and you have to access them through subdomains, then you need to configure Apache.

=================== Configuring the local domain name =====================

If only as a local access, you only need to configure hosts and httpd.conf to

1. Add "127.0.0.1 custom domain name in the host file (C:\WINDOWS\SYSTEM32\DRIVERS\ETC)"

127.0. 0.1    Test.host.com

With the above steps, you can use test.host.com to access the local server. But only to do these meager jobs, the server will not know the difference between localhost and test.host.com. Therefore, it is also necessary to configure the virtual host for Apache to assign different processing paths for different domain name requests.

2. In the httpd.conf file (C:\wamp64\bin\apache\apache2.4.17\conf), add

Namevirtualhost *:<virtualhost *: >    "c:/users/administrator /desktop/test"    ServerName test.host.com    "c:/users/administrator /desktop/test">        Require local    

In this step you will need to modify the DocumentRoot (project path) and ServerName (custom domain name) to your own. Directory is a catalog that users can access, and the project path remains consistent. Note that the parameters in Directory Require Local, which means that only local access is allowed, and if you change it to Require all granted, then anyone can access the directory.

================== assigning site domain names =====================

If it is intended to be deployed in the actual project, then the situation will be relatively troublesome, but the idea is still all the two-level domain name requests to the same server processing, and then through the virtual host for different domain requests to assign different processing paths.

1. Assign subdomains to the primary domain by the cloud resolution provider, and then bind the host IP to the sub-domain name.

2. Modify the httpd.conf file to remove the comments in front of the Include conf/extra/httpd-vhosts.conf.

3. In the httpd-vhosts.conf file (C:\wamp64\bin\apache\apache2.4.17\conf\extra), add

<virtualhost *:>servername"Two-level domain name"documentroot"project path    "<directory"Access Directory">         allowoverride All        Require all granted    </Directory></VirtualHost>

Require all granted allow external access/Require all denied prohibit external access

AllowOverride all allows. htaccess to override the URL/allowoverride none to ignore. htaccess files

The above steps are simple, but you have to work on it again and again. If you still don't understand, you can start by configuring your local domain name and then step into it.

================== Precautions ======================

Two-level domain name definition rules

WWW: main entrance to the website (www.baidu.com)

Mail: Typically used to resolve mailbox servers (mail.baidu.com)

M: Domain name for mobile website (m.baidu.com)

Apache Access Control permissions

The 2.2 release allows all requests: the Order Allow,deny #排序, allow after deny allowed from all #允许所有

Version 2.4 allows all requests: Require all granted #允许所有

Restarting the server

After modifying the Apache configuration file, you must restart the server configuration to take effect

Apache Configuring multi-site Access "Assigning a two-level domain name to a project"

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.