Multi-site configuration of Virtual Hosts

Source: Internet
Author: User

1. Enable multi-site configuration in the Apache configuration file (httpd. conf), so the location of the multi-site configuration file httpd-vhosts.conf is clear at a glance.

Note: Once a multi-site configuration (httpd-vhosts.conf) is performed, the original configuration file (httpd. conf) becomes invalid.

2. multi-site configuration

<Virtualhost> command: contains commands that only act on the specified host or IP address, including IP addresses, port numbers, and other information. The default Apache port on this machine is 8080.

Servername command: used to identify the name and port number of the VM.

Serveralias command: matches a domain name-based virtual host alias

DocumentRoot command: the root directory of the main document tree visible on the network

<Directory> command: this command is used to encapsulate a group of commands so that it is only valid for a directory in the file Space and Its subdirectories. It contains the root directory path directory-path information and can be matched using regular expressions.

AllowOverride none indicates disabling commands in the. htaccess File

Note: Apache's default access permission to <directory> is "allow from all", which means Apache will allow any files mapped through URLs. However, we recommend that you add order to block it.

<Directory/>

# Deny first, and then allow

Order deny, allow

# Client access is prohibited only if no access is allowed.

Deny from all

</Diretory>

Then overwrite the configuration in the directory you want to make it accessible.

The complete code is as follows:

<Virtualhost *. 8080>

# Domain name. If no port number is specified, the requested port number is used by default. To enhance reliability and predictability, you should explicitly specify the port number

Servername www.motex.com: 8080

# Domain name-based virtual host alias

Serveralias motex.com

DocumentRoot "C: \ amp \ apache \ htdocs"

<Directory "C: \ amp \ apache \ htdocs">

# Allow the client to traverse directories and Their subdirectories

# Only the local host 192.168.31.102 is allowed to access the virtual host www.motex.com

Order deny, allow

Deny from all

# Local IP address 192.168.31.102

Allow from 192.168.31.102

</Directory>

</Virtualhost>

3. Let's take a look at my frequently-used phpMyAdmin configuration.

Test OK

 

 

 

 

Multi-site configuration of Virtual Hosts

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.