简体   繁体   中英

Virtual Host on Xampp for Laravel is not working

Hello i am learning Laravel and trying to modifying vhost file of my xampp server for laravel practice project, but its not working. code of vhost file is

<VirtualHost *:80>
    DocumentRoot "D:/xampp/htdocs/laravel5Prc/public"
    ServerAdmin admin@localhost
    ServerName laravel5.prc
    ServerAlias laravel5.prc

    <Directory "D:/xampp/htdocs/laravel5Prc/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.121
       # Only if you want the world to see your site
       #Require all granted
    </Directory>
</VirtualHost>

i have taken this code from this url How to enable Virtual Host on Xampp for Laravel?

its not working form me, anyone please guide me what am i doing wrong in it?

why you don't use php artisan serve to run laravel on localhost.

from https://laravel.com/docs/5.4/

I'm strongly recommend you to use Laravel's vagrant box called Homestead instead of xampp, it's really amazing! You can read about it here . It's much more flexible and easier to understand than anything else.

I was using php-7.3.2 and had similar problem. This is not the solution to the problem, but an alternative. I went back to php-7.1.25 and ran again. I'm still going to check out what the problem is with version 7.3 and laravel, but maybe this will help some people who come here with the same problem.

This is what you should do, add or uncomment this below at the top of the xampp vhost file

NameVirtualHost *:80

Change this to you valid assumed domain and add the Directory index

ServerName laravel5.test
ServerAlias laravel5.test
DirectoryIndex index.php

And then go to the this folder C:\\Windows\\System32\\drivers\\etc\\hosts in windows and add your domain of choice for example see this below

127.0.0.2      laravel5.test
127.0.0.3      anotherdomain.test

**** Please note don't use the localhost or 127.0.0.1 created by default to set yours's you should create you own eg (127.0.0.2, 127.0.0.3, 127.0.0.4) in that order

After then restart you xampp server you should be good to go

**** I notice your Document and Directory has this "D:/xampp/htdocs/laravel5Prc/public" change the D to C and please I would advise your laravel project should be outside the xampp folder, you can use the Document folder for this.

//Open C:\Windows\System32\drivers\etc\hosts
127.0.0.1  laravel5.prc

//Open xampp/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
  ServerAdmin webmaster@dummy-host2.example.com
  DocumentRoot "C:/xampp/htdocs/laravel5Prc/public"
  ServerName laravel5.prc
  ErrorLog "logs/dummy-host2.example.com-error.log"
  CustomLog "logs/d`enter code here`ummy-host2.example.com-access.log" common
</VirtualHost>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM