Home > Article > Backend Development > Apache virtual host configuration
ApacheVirtual host configuration
* Conditions: Include httpd-vhosts.conf in http.conf
* # Virtual hosts
Include conf/extra/httpd-vhosts.conf
* Configure in httpd-vhost.conf
* ( 1) IP-based virtual host
* Modify the hosts file and add 3 corresponding domain names
* 192.168.1.11 www.test1.com
* 192.168.1.12 www.test2.com
* 192.168.1.13 www.test3.com
* Establish the root directory where the virtual host stores files, such as
* www/test1/1.html
* www/test2/2.html
* www/test3/3.html
* Perform the following configuration in 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
* & lt;/directory & gt;
* & lt;/virtualhost & gt;
* T & lt; virtualHost 192.168.1.12:80> ;
Servername www.test2.com
DocumentRoot /www/test2/
< Order allow,deny
“ VirtualHost>
*
*
gt;
Options Indexes FollowSymLinks
AllowOverride None
Order Allow, DENY
Alow from All
& LT;/Directory & GT;
& LT;/VirtualHost & GT; eSt1.com e* 192.168.1.10 www.test2.com
* 192.168.1.10 www.test3.com
* Set the root directory to store the web page
* 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's IP address and possible access port to enable the host to accept requests. You can use the NameVirtualHost directive to configure it. If all IPs on the server will be used, You can use * to indicate,
* The IP specified in NameVirtualHost will not let the server listen to this IP
* Then configure
* If you configure a virtual host on an existing WEB server, it must be an existing virtual host The host is also configured with
* ServerName and DocumentRoot should contain the same content as the global content, and should be placed at the front of the configuration file,
* as the default host configuration
* NameVirtualHost *:80
* < ;VirtualHost *:80>
* * ServerName www.test1.com
* * DocumentRoot "www/test2"
* *
* * Options Indexs FollowSymLinks
* * AllowOverride None
* Order allow,deny
* * ServerName www.test2.com
* * DocumentRoot "www/test2"
*
* * Options Indexs FollowSymLinks
* * AllowOverride None
* Order allow,deny
* * allow from all
* * < ;/Directory>
* *
* *
* * ServerName www.test3.com
* * DocumentRoot "www/test3"
* ">
* FollowSymLinks
use using use using using using ‐ ’ ’ ’ ’ ’ ’ ’ using ’s using ’s ’ s -- -- - ,
*
* (3) Based on port
* Modify httpd.conf
* Set to Listen 8001
* Listen 8002
* Modify the virtual host configuration file httpd-vhosts.conf
mentRoot "www/test1"
* * VirtualHost>
* *
* * ServerName www.test2.com
* * DocumentRoot "www/test2"
* *
The above introduces the configuration of the Apache virtual host, including Apache content. I hope it will be helpful to friends who are interested in PHP tutorials.