How To Setup An Apache VHOST For XAMPP And Laravel

How to setup a VHOST that works with XAMPP, Laravel 9 and Windows 10.

Open the Apache file httpd-vhosts.conf. Depending on where you’ve installed XAMPP, the location could be something like:

C:\xampp\apache\conf\extra

Here’s a shortcut to get there:

  1. Open XAMPP’s CP and click on the Apache row of buttons: ‘Config’, then ‘<browse> Apache’.
  2. This will open an explorer window in the Apache directory.
  3. Navigate to the directory ‘conf/extra’.
  4. You should see httpd-vhosts.conf in the list of files.
  5. Open this file in any text editor. We recommend Notepad++.

Add your VHOST entry. The following is an example – be sure to edit the following three items to match your own config:

  1. DocumentRoot: The location of your Laravel 9 app public directory
  2. ServerName: Your local domain name for the app
  3. Directory: The location of your Laravel 9 app root directory
<VirtualHost *:80>
DocumentRoot "E:/projects/laravel-app/public"
ServerName laravel-app.local
<Directory "E:/projects/laravel-app">
  Options Indexes FollowSymLinks MultiViews
  AllowOverride all
  Order Deny,Allow
  Allow from all
  Require all granted
</Directory>
</VirtualHost>

Update your Windows 10 ‘hosts’ file.

This will allow you to access your project via a local domain name of your choice. The hosts file can be found in:

C:/Windows/System32/drivers/etc/

Add an entry for the project’s local domain name, for example:

127.0.0.1 laravel-app.local

That’s it. You should now be able to access your laravel 9 app by typing the local domain name into your browser. Be sure to restart Apache if it’s already running.

Related Posts
Leave a Reply

Your email address will not be published.Required fields are marked *