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:
- Open XAMPP’s CP and click on the Apache row of buttons: ‘Config’, then ‘<browse> Apache’.
- This will open an explorer window in the Apache directory.
- Navigate to the directory ‘conf/extra’.
- You should see httpd-vhosts.conf in the list of files.
- 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:
- DocumentRoot: The location of your Laravel 9 app public directory
- ServerName: Your local domain name for the app
- 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.