In my previous post we have successfully installed laravel on xampp and tested via php artisan serve command. Artisan is the command line interface included in laravel. We will discuss more about artisan in my upcoming posts. SO if you want read by yourself then visit Artisan Console on official laravel documentation.
But this means every time I want to run laravel, I have to use artisan serve command?
No no, You can also access laravel by hitting
localhost/laravel_folder_name/public. In our installation tutorial I renamed laravel folder to
my_site. Below is the screenshot in which laravel site is showing using localhost/my_site_public
By default laravel uses
public/index.php to jump into its eco system. But using
localhost/laravel_folder_name/public may create some internal linking problem in development.
To overcome this issue most of the PHP developers (including me) create virtual host for localhost . According to wikipedia:
Virtual hosting is a method for hosting multiple domain names (with separate handling of each name) on a single server (or pool of servers). This allows one server to share its resources, such as memory and processor cycles, without requiring all services provided to use the same host name.
Configure Virtual Host for Laravel in XAMPP:
Now you know what is Virtual Host. Now lets configure virtual host for laravel in xampp. I will create virtual host as
mysite.laravel. There are 2 steps involve which are.
- Add/point Virtual host entry in
httpd-vhosts.conffile. This file normally falls in
- Point Virtual host entry to
hostsfile. Hosts file path is
Add Laravel Folder Path to http-vhosts.conf:
I have installed xampp in
D:\ drive so my
http-vhosts.conf file path is
http-vosts.conf file and paste below code at the bottom.
Options Indexes FollowSymLinks
Require all granted
Add Laravel Folder Path to hosts file:
Normally hosts file path is
C:\Windows\System32\drivers\etc\hosts. Open hosts file as an Administrator.
Once both entries are done restart your xampp apache service and goto browser and type
mysite.laravel. You will see laravel default page.