1. Open the Apache configuration file httpd.conf See if the virtual host is open
#Include conf/extra/httpd-vhosts.conf to remove the previous #.
2. Open apache\conf\extra\httpd-vhosts.conf
Add the following code:
<virtualhost *:80>
DocumentRoot path under "D:/www/cms"--www
ServerName m.local.cc--URL to access
Errorlog "Logs/m.local.cc-error.log"
Customlog "Logs/m.local.cc-access.log" common
<directory "D:/www/cms" >
Options Indexes FollowSymLinks
DirectoryIndex index.html index.php
AllowOverride All
Order Allow,deny
Allow from all
</Directory>
</VirtualHost>
Let me talk a little bit about what the above code needs to change:
<virtualhost *:80> Here is the access port, if you are the other port please modify it yourself
DocumentRoot "D:/www/cms" This is the project's specific path, that is, you want to open the virtual host project
ServerName m.local.cc This (m.local.cc) is the URL you want to visit this project
Errorlog "Logs/m.local.cc-error.log" specifies the file saved by the error log
<directory "D:/www/cms" > here to keep the same as the project path
DirectoryIndex index.html index.php defines the index, which is the default access (index.html or index.php if present) when the project name is entered, but the specified access file is not entered.
3. Open C:\Windows\System32\drivers\etc\hosts File
Configure the IP that the local domain name points to, add it in the bottom-most space of the file ( the URL you write in httpd.conf must correspond ):
127.0.0.1 m.local.cc
After this, the entire local virtual host is configured to complete, and then reboot the Apache server! this is important.
Configuring a virtual Host