Install and configure Laravel 5 with WAMP server in VirtualHost
In this tutorial, I am going to show you how to install Laravel 5.5 on WAMP server and a simple way to create and configure a VirtualHost using WAMP server.
Create Project Directory:
First of all download and install a fresh copy of WAMP server in your development machine if you don't have any previous installed WAMP server. Now create a folder with the name "laravel.dev", it's better to create a directory same as your project name in "www" directory mine is "C:/wamp/www/laravel.dev"Warning: Always remember to use .dev or .local extension instated of .com, .net or .org to create a Virtual Directory. This two extension are commonly used to create VirtualHost for development environment.
VirtualHost Configurations
Now we have to configure this directory to our WAMP server so that we can directly visit this ( http://laravel.dev ) Url from our web browser. This can be done two ways, Manually and Automatic. In this tutorial i do this automatic way . New WAMP server has this option to configure VirtualHost automatically.Automatic Configuration:
Step 1: Visit http://localhost.Step 2: Click on Add Virtual Host.
Now you can see this configuration page to configure your VirtualHost directory. In hare you have put your configuration information.
Step 3: Here you can find 3 input fields but you have to fill only 2 of them, first and third one which marked as Red box.
- First input field for my VirtualHost Domain name, in that case laravel.dev is my input value because i want to visit my project as http://laravel.dev.
- Second input field for Directory location so that WAMP server can find out my project directory in this (http://laravel.dev) virtual domain name, so the input value is C:/wamp/www/laravel.dev .
- Unmarked input field is optional, right now you don't need to provide any input for this field.
Step 4: Click on Start the creation of the VirtualHost button.
After click on this button WAMP server automatically assign this information in virtual host configuration file as well as in https file in System32 directory.
Step 5: Restart you WAMP server.
Step 6: Visit http://laravel.dev if everything setup perfectly you will see this page.
Ooops..! 😨😨 Now you are thinking what the hell is this.! It's suppose to show Laravel default home page. I know you are also thinking that maybe this problem is for .htaccess file which is mention in Laravel offical website but it is not.!
Fix Laravel Route not working with WAMP:
Before fix this problem you have to know that in Laravel framework there is a public/.htaccess file, the main purpose of this file is that in every request it will hide index.php file to make a Pretty Urls , so you can think that every request you send to Laravel application it's pass via .htaccess file to index.php so practically Laravel root directory is /public folder not the application content directory. If you visit here http://laravel.dev/public you can see Laravel default home page.Ok let's fix this problem, now back to Step 3 where you are configure your VirtualHost domain & directory. You have to only update the VirtualHost directory location from C:/wamp/www/laravel.dev to C:/wamp/www/laravel.dev/public so that when you send any request to your application every request can find the .htaccess file. Unfortunately there is no simple way to update this location you have to do it manually.
Update VirtualHost Directory Location:
Step 1: Go to C:\wamp\bin\apache\apache2.4.23\conf\extra directory in your development machine.Step 2: Open httpd-vhosts file in this directory. Using any text Editor
Inside this file you can find you VirtualHost Configuration text something like that.
<VirtualHost *:80>
ServerName laravel.dev
DocumentRoot "c:/wamp/www/laravel.dev"
<Directory "c:/wamp/www/laravel.dev/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Step 4: Now you have to update DocumentRoot and Directory location. So it will be look like bellow text.
<VirtualHost *:80>
ServerName laravel.dev
DocumentRoot "c:/wamp/www/laravel.dev/public"
<Directory "c:/wamp/www/laravel.dev/public/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Look carefully i am just add public directory in DocumentRoot & Directory address.Step 5: Save this file and Restart WAMP server again.
Step 6: Now visit http://laravel.dev again this time you can see default home page.
Note: Whenever you update or modified WAMP server configuration file you must Restart the WAMP server, otherwise the change not affect the server.
Hi,
ReplyDeletethanks for sharing useful information,
Providing Laravel Web Developmentl shopping cart, Website Designing and Payment gateway integration.
Ecommerce Website Development
Online Business Website Development
Ecommerce Portal Development
For more details about my Web Development and Laravel Web Development Services.
You are a life saver. My php artisan serve has been malfunctioning. This got me started on my new project .
ReplyDelete