How to enable Virtual Host on Xampp for Laravel?

后端 未结 3 432
别跟我提以往
别跟我提以往 2020-12-14 22:33

I have XAMPP running on Windows 7 Pro. I am trying to setup a Virtual Host so that when I use \"dev.app\" as a domain I get directly to my public folder of laravel installat

相关标签:
3条回答
  • 2020-12-14 23:20

    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
    

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

    NameVirtualHost *:80
    

    is no longer required or allowed for Apache 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>
    
    0 讨论(0)
  • 2020-12-14 23:28

    Use laragon server instead of XAMPP. One of useful features of Laragon is Auto Virutal Hosts. learn more about Pretty URLs with laragon here

    0 讨论(0)
  • 2020-12-14 23:37

    `open C:\xampp\apache\conf\httpd.conf, locate at

    Virtual hosts

    #Include conf/extra/httpd-vhosts.conf, remove # in this line, save file, Restart server`

    0 讨论(0)
提交回复
热议问题