: This article mainly introduces the configuration of Apache virtual host. if you are interested in the PHP Tutorial, refer to it.
ApacheVirtual host configuration
* Condition: include httpd-vhosts.conf in http. conf
* # Virtual hosts
Include conf/extra/httpd-vhosts.conf
* Configure in httpd-vhost.conf
* (1) IP-based VM
* Modify the hosts file and add three domain names
* 192.168.1.11 www.test1.com
* 192.168.1.12 www.test2.com
* 192.168.1.13 www.test3.com
* Create a root directory for storing files on the VM, as shown in figure
* Www/test1/1.html
* Www/test2/2.html
* Www/test3/3.html
* Configure the following in the httpd-vhosts.conf
*
* ServerName www.test1.com
* DocumentRoot "www/test1"
*
* Options Indexs FollowSysLinks
* AllowOverride None
* Order allow deny
* Allow from all
* DirectoryIndex index.html index.htm index. php
*
*
*
*
ServerName www.test2.com
DocumentRoot/www/test2/
Options Indexes FollowSymLinks
AllowOverride None
Order allow, deny
Allow From All
*
*
ServerName www.test3.com
DocumentRoot/www/test3/
Options Indexes FollowSymLinks
AllowOverride None
Order allow, deny
Allow From All
*
* (2) based on the host name
* Set domain name ing to the same host
* 192.168.1.10 www.test1.com
* 192.168.1.10 www.test2.com
* 192.168.1.10 www.test3.com
* Set the root directory for storing web pages
* Www/test1/1.html
* Www/test2/2.html
* Www/test3/3.html
* When using a domain name-based virtual host, you must specify the server IP address and possible access port to make the host accept the request.
* Use the NameVirtualHost command for configuration. If all the IP addresses on the server are used, you can use * to represent the IP addresses,
* The ip address specified in NameVirtualHost does not allow the server to listen to this IP address.
* Then Configure
* If you configure a virtual host on an existing WEB server, you must configure the virtual host as well. , Where
* ServerName and DocumentRoot should contain the same content as the global content and be placed at the beginning of the configuration file,
* As the default host configuration
* NameVirtualHost *: 80
*
* ServerName www.test1.com
* DocumentRoot "www/test2"
*
* Options Indexs FollowSymLinks
* AllowOverride None
* Order allow, deny
* Allow from all
*
*
**
* ServerName www.test2.com
* DocumentRoot "www/test2"
*
* Options Indexs FollowSymLinks
* AllowOverride None
* Order allow, deny
* Allow from all
*
*
**
* ServerName www.test3.com
* DocumentRoot "www/test3"
*
* Options Indexs FollowSymLinks
* AllowOverride None
* Order allow, deny
* Allow from all
*
*
*
* (3) port-based
* Modify httpd. conf
* Set to Listen 8001
* Listen 8002.
* Modifying the VM profile httpd-vhosts.conf
*
* ServerName www.test1.com
* DocumentRoot "www/test1"
*
**
* ServerName www.test2.com
* DocumentRoot "www/test2"
*
The above describes the configuration of the Apache virtual host, including the Apache content, and hope to be helpful to friends who are interested in the PHP Tutorial.