且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Xampp 上为 Laravel 启用虚拟主机?

更新时间:2023-02-24 13:50:33

hosts 文件应该是这样的,这样就可以在 IPV4 和 IPV6 网络上找到它

The hosts file should look like this so that it can be found on the IPV4 and IPV6 networks

127.0.0.1  localhost dev.app
::1        localhost dev.app

如果您使用的是 Apache 2.4.x,请在 httpd-vhosts.conf

If you are using Apache 2.4.x this line in httpd-vhosts.conf

NameVirtualHost *:80

不再需要或允许用于 Apache 2.4.

is no longer required or allowed for Apache 2.4.

vhost 文件应该是这样的,你混合了 Apache 2.2 和 2.4 语法,虽然只要你激活了 mod_access_compat 任何一种都是允许的,你不应该混合它们,2.4 语法更好.您还错过了一些其他有用的点点滴滴

The vhost file should look like this, you mixed Apache 2.2 and 2.4 syntax and while either is allowed as long as you have mod_access_compat activated, you should not mix them and the 2.4 syntax is better. You also missed a few other useful bits and pieces

<VirtualHost *:80>
    DocumentRoot "F:/xampp/htdocs/"
    ServerAdmin admin@localhost
    ServerName localhost

    <Directory "F:/xampp/htdocs/">
       Options Indexes FollowSymLinks
       AllowOverride all
       Require local
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "F:/xampp/htdocs/dev/public"
    ServerAdmin admin@localhost
    ServerName dev.app
    ServerAlias www.dev.app

    <Directory "F:/xampp/htdocs/dev/public">
       AllowOverride All
       Options Indexes FollowSymLinks

       Require local
       # if you want access from other pc's on your local network
       #Require ip 192.168.1
       # Only if you want the world to see your site
       #Require all granted
    </Directory>
</VirtualHost>