This article explains in detail how to configure a virtual host and what to pay attention to when configuring a virtual host. Apache 2.4 is used as an example.
1,Modify httpd. conf
Remove the # in the second line below to start the virtual host configuration
# Virtual hosts # Include conf/extra/httpd-vhosts.conf
2. configure httpd-vhost.conf
Port 8081 is used and two virtual hosts are configured. DocumentRoot cannot contain Chinese directories.
ServerName localhost DirectoryIndex index.php DocumentRoot "D:\Work\php\Apache24\htdocs"
Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all
ServerName www.aa.com DirectoryIndex index.php DocumentRoot "E:\php\PhpProjectBase"
Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all
3. etc/hosts configuration
127.0.0.1 localhost127.0.0.1 www.aa.com
4. restart the Apache service.
If the VM is still inaccessible, configure the following items in httpd. conf:
AllowOverride none #Require all denied
The preceding section describes how to configure a virtual host using Apache in php. For more information, see other related articles in the first PHP community!