Note: To start with, the only difference for this guideline, between XAMPP and WAMP or other Apache packages for Windows, is question where those packages are installed on your computer.
Introduction: vhost (virtual host) is a great solution if you intend to develop many independent project in php and keep them isolated from each others, like:
You will use the default 3306 and 5432 ports in your Laravel application's database configuration file since Laravel is running within the virtual machine. Database Backups Homestead can automatically backup your database when your Homestead virtual machine is destroyed. #2 XAMPP Virtual Host. If you are looking to assign a permanent domain to your project, you can do so by configuring the xampp virtual host. We need to configure XAMPP Virtual Host to set the document root to correct directory of laravel project and to also assign a name to the project by which we will be accessing it in browser.
- Project 1 is based on php and has local url address
- Project 2 is a Laravel project with url
- Project 3 is a Codeigniter with url
- Project 4 is a WordPress with url
You are expected to have installed the latest version of XAMPP/WAMP. Btw, in my case, I have only installed Apache and MySQL.
*Note: By default, most web servers will uses port 80 as default port, in some situation if you have another web server installed like (Microsoft IIS), it uses port 80 as well OR in other cases SKYPE does also some times use port 80 like it is the case for some in Windows 8/10 for some users, in that case you can do two thing’s
- In XAMPP, a virtual host is the name given to the localhost so that the developer can easily access assets without the issue of broken links or similar issues. A XAMPP installation can have multiple virtual hosts.
- E very time running a Laravel application with the command “php artisan serve” may be painful. When it comes to multiple laravel projects running at a time is a nightmare. It will be helpful if you.
- Copy “hosts” file from Desktop and paste it back to “C: Windows System32 drivers etc”. Now, open WAMPP (XAMPP) and restart Apache server. In your browser, navigate to project-name.dev (ex: projectD.dev) This is how you can set up virtual host in your xamp or wamp server for laravel.
- Change your Apache port to port
8081etc. or some other free ports (note: 8080 can some times also give some problems)
- OR Change your others software/IIS port and keep Apache to default port 80 in case of Skype, just kill the Skype app and restart it after installing Apache on port 80, Skype will automatically get new port.
I have chosen to change my Apache to port 8080.
– For next section, we need to use text editor like notepad or regular IDE. I used sublime text editor.
– If you keep Apache to default port 80, skip this part and move on to Virtual hosts
Change XAMPP/WAMP port (only if necessary)
if left default, then jump to Setting virtual host
Step 1. Edit httpd.conf
Click on Config -> Apache (httpd.conf)
Or you find the file here
C:Bitnamiwampstackapache2confhttpd.conf or similar location.
Change the line with
To 8080 or other, free ports.
While we have
httpd.conf file open we need to ensure that
httpd-vhosts.conf is included:
Note: By default server documents are locate on
C:Bitnamiwampstackapache2htdocs that’s fine if you have only one project or many small test files. However, if you need to develop many projects then it suggested separating them by virtual host, as mentioned earlier.
Step 2. Setting Virtual host Acronis activation.
Configurar Virtual Host Xampp Laravel
- Create a folder for your projects; I have create one in
c:vhostyou can call it projects etc.
c:vhostfolder we create a sub-folder domain1 or project1 or any other, it is up to you (
C:XAMPPapacheconfextrahttpd-vhosts.confAdd following code in line depending on how many vhost you want to create:
Note: If you work on Laravel projects you can create unlimited Laravel projects as well as other frameworks like codeigniter, Yii, etc., the point is to
have your Laravel project/s on
c:vhostlaravel2 etc and make
DocumentRoot etc as showed before. Each Laravel project will have own
Save and close the file
Some additional information and notes:
- If port is remain default 80 then the URL address will be
- If port is remain default 80 then the the VirtualHost tag should be changed to
- If port is changed to
8080, the URL address will be
- And the vhost URL address could look like this
- You can add unlimited projects and virtual host like this way.
We are not ready yet, read more.
Step 3. Edit Windows Host file
- Stop Apache and MySQL services from XAMPP/WAMP.
- Open hosts file in
you need Administrator privilege to edit the file.
I suggest to edit the file directly with Sublime text editor.
127.0.0.1 project1.localhostat the end of the file, Save and close the file.
save the file
Start/Re-start your Apache and MySQL again.
Note: You might need to delete your cache in your browser and also it
is good to disable php cache under development process.
php.ini under php folder in your XAMPP or WAMP folder and
Addition (Alternative solution)
It is possible to deploy temporary Virtual Server with out necessarily configuring XAMPP/WAMP Virtual Host, start CMD console and run following php command:
- Port 8001 can be change to any available port number and be sure nor conflicting with other software ports.
c:vhostLaravel..path should be changed to what ever your project path.
- It is possible to start multiple servers but should have different port numbers.
Laravel Virtual Host Xampp
In your browser you need only to right
Note on 403 Access forbidden error
If you get a 403 Access forbidden error when you browse to your site, you may need to add this to your httpd.conf file:
virtual host for a Laravel in Xampp?
Developers, need to create virtual hosts in xampp to run multiple projects because that is much easier than accesing the direct path of localhost URL. Creating a virtual host in xampp is very easy, however you may need to configure it correctly for a Laravel project and today we are going to share with you how to do it very easily.
1. Creating a local URL for your laravel app
In this post we want to access our laravel project from the browser accesing the URL //laravel.localhost.com, so you need to modify the hosts file of Windows located in
Laravel Virtual Host Xampp Software
Remember to edit the hosts file using an editor with administrator rights, otherwise you will not be able to save the changes. you can copy host file at desktop and make changes then again copy changed/repalce existing host file into etc folder. Then add the host using a custom host on your system, in this case we will add the
127.0.0.2 host that will be accesible as well with an alias of
Laravel Virtual Host Xampp Tutorial
You can increase the final number of the host to have multiple of them e.g 127.0.0.3, 127.0.0.4 etc for multple projects.
2. Creating a Virtual Host
The main entry point of a laravel application is the index.php located inside the public folder, so the main directory for our application will be the absolute path to your project in the public folder as shown in the following example. The virtual host should be point out the same host declared in the hosts file of windows (in this case
127.0.0.2) at the port 80. You can create this virtual host appending the following snippet at the end of the content of the
httpd-vhosts.conf file located in the xampp folder
Finally, by visiting either //laravel.localhost.com or 127.0.0.2 in your browser will show the entry point of your Laravel application: