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