해외축구중계스포츠중계축구중계EPL중계스포츠무료중계실시간스포츠
Configure Virtual Host for Laravel in XAMPP - WDB24
Site icon WDB24

Configure Virtual Host for Laravel in XAMPP

laravel featured image

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.

  1. Add/point Virtual host entry in httpd-vhosts.conf file. This file normally falls in xampp\apache\conf\extra folder.
  2. Point Virtual host entry to hosts file. Hosts file path is C:\Windows\System32\drivers\etc\ on windows.

Add Laravel Folder Path to http-vhosts.conf:

I have installed xampp in D:\ drive so my http-vhosts.conf file path is D:\xampp\apache\conf\extra\httpd-vhosts.conf. Open http-vosts.conf file and paste below code at the bottom.

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.

Exit mobile version