System Administration

Create virtual host on XAMPP

Some time for create custom project url there we need to give a name for the project and we want that project according to their name like abc is my project and I want it to run on abc.com so when the project will be hosted on live server it will not make any difference for abc.com domain. Virtual host on XAMPP is very easy process , Just follow bellow instruction to create virtual host on XAMPP

First I am going to assume you’re using a Windows machine and have XAMPP installed. Open the XAMPP control panel application and stop Apache. … Navigate to C:/xampp/apache/conf/extra or wherever your XAMPP files are located. Open the file named httpd-vhosts.conf with a text editor.

then input the configuration bellow : make sure to change your file location to DocumentRoot, Directory and change ServerName.

<VirtualHost *:80>
DocumentRoot "/Volumes/Storage/niamrox.dev/web/practice/batch_1_project"
ServerName habizabi.com
<Directory "/Volumes/Storage/niamrox.dev/web/practice/batch_1_project">
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>

After that restart your Apache Server by Xampp service.

Find your own pc IP address.

Then find and open host file. If you are windown user edit

C:\Windows\System32\Drivers\etc\hosts

If you are OSX / Mc user then open terminal and and copy paste the following code below ‘sudo nano /private/etc/hosts’

at host file write your ip address and server name like bellow

192.168.1.2 habizabi.com

After that restart your apache server and browse the server name on browser. You will find the project there.

By this way you can test the project before deployment or when the project will be deployed on live server it will be same as the domain. For linux or mac almost all are similar just make sure about changing the host file.

If you want to change host file at ubuntu then follow the command bellow

sudo nano /etc/hosts

here nano is a editor , you can use any others editor by its terminal command like if you want to edit on gedit text editor then apply the following command

sudo -E gedit /etc/hosts

Then edit as per your requirement.

if you are using mac then there is a visual tools you can edit host file easily. Download and install Gas Mask host file editor from here.

You Might Also Like

One comment

  1. 1

    could point to two separate applications on the same server. Or, you could create separate domains, such as Virtual hosts created in this manner will not be accessible from other systems, unless those systems are separately configured to associate the custom domain used by the virtual host with the IP address of the XAMPP server. This guide walks you through the process of setting up a new virtual host with XAMPP, by creating and configuring an example host named

Leave a Reply

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