Configure multiple virtual hosts because there are multiple laravel projects that need to be configured with the root directory under public
Method One: Add a port number
- The first step: Enter the Apache directory apache24\conf find httpd.conf file, under Listen 80 plus Listen Bayi
- Step Two: Enter the httpd.conf file's sibling directory Apache24\conf\extra find the httpd-vhosts.conf file, at the end of the file add
<virtualhost *:bayi>"E:\PHP\exam\public" Change the path to your own </ Virtualhost>
- Step three: After you restart Apache, you can access localhost:81 directly in the browser.
Method Two: Add host name
- First step: Go to directory C:\Windows\System32\drivers\etc find the hosts file, add 127.0.0.1 XXXX (name to own) at the end of the file
- Step Two: Enter the Apache directory Apache24\conf\extra find the httpd-vhosts.conf file, at the end of the file add
<virtualhost *:> ServerName exam.cn name changed to own documentroot E: / Php/exam/public Path to its own <directory "e:/php"> +indexes +includes +followsymlinks +multiviews allowoverride all Require Local </Directory></VirtualHost>
- Step three: After you restart Apache, you can access exam.cn directly in the browser.
Configuring virtual hosts under Windows Apache