0

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 ?

Umair Mehmood
  • 514
  • 1
  • 11
  • 24
  • Have you tried restarting the Apache service? What error are you getting? Please run `apache -S` and `apache -t` in your terminal or post your error log. – Aiman Daniel Sep 09 '17 at 09:26
  • yes i restarted the server several times and when i run laravel5.prc in google chrome this error occurss `**This site can’t be reached** _laravel5.prc_server DNS address could not be found. Try running Windows Network Diagnostics. DNS_PROBE_FINISHED_NXDOMAIN` – Umair Mehmood Sep 09 '17 at 09:32
  • Try mapping `laravel5.prc` to `127.0.0.1` in your Windows hosts file. Then, type in `ipconfig /flushdns` in your terminal. – Aiman Daniel Sep 09 '17 at 09:37
  • I tried it and now its atlest working but `laravel5.prc` is redirecting to `laravel5.prc/dashboard/` – Umair Mehmood Sep 09 '17 at 10:12
  • now every thing is working, thanks for your valuable time and guideline . really appreciate your help .. – Umair Mehmood Sep 09 '17 at 10:16
  • Have you enabled the virtual host? – Stefano Maglione Sep 09 '17 at 11:59

5 Answers5

0

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.

0

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.

0

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 e.g. (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.

Okechukwu Obi
  • 409
  • 4
  • 8
0
//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>
Abid Shah
  • 325
  • 3
  • 5
-1

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

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

  • 1
    because i dont want to run `php artisan serve` command each time i restart the server. and type the IP instead of just typing the short and easy understand able url of my practice. as wel as there are some issue with Rout when i run the `php artisan make:auth` so some one also suggested to over wride that issue try to access with vhost . check the url for Auth [https://stackoverflow.com/questions/46050068/notfoundhttpexception-in-routecollection-php-line-179-in-laravel-5-4](https://stackoverflow.com/questions/46050068/notfoundhttpexception-in-routecollection-php-line-179-in-laravel-5-4) – Umair Mehmood Sep 09 '17 at 09:03