- Windows 7 32 bits
- Xampp with PHP 5.6 and control panel version 3.2
Apart from the naming flexibility and simulation of the production environment locally, setting up a virtual host makes it very easy for you to run and test apps found on your local git repository without pain. All you need to do is to set the path to the app of interest in your local git repository when configuring its virtual host. Configure your virtual host by going through the following steps
Step 1: Enable the and configure virtual host
- Locate the httpd-vhosts.config file found at ‘/xampp/apache/conf/extra’ directory.
Open it using a text editor ( Notepad++ for example ). Uncomment the line with the statement ‘NameVirtualHost *:80’ by deleting/removing the preceding hash ‘#’ character. You will find it about line 20.
Move to the last portion of the file, start a new line and type the following
ServerAdmin webmaster@localhost DocumentRoot "F:/xampp/htdocs" ServerName localhost <Directory "F:/xampp/htdocs"> Require all granted AllowOverride All Options Indexes FollowSymLinks ServerAdmin email@example.com DocumentRoot "path/to/project1" ServerName localhost.project1 <Directory "path/to/project1"> Require all granted AllowOverride All Options Indexes FollowSymLinks ServerAdmin firstname.lastname@example.org DocumentRoot "path/to/project2" ServerName localhost.project2 <Directory "path/to/project2"> Require all granted AllowOverride All Options Indexes FollowSymLinks
Restart your xampp.
Step 2: Edit your host file
Launch notepad with administrative rights by simply right clinking on it icon then select ‘Run as administrator’. Once the User Account Control prompt appears, click ‘yes’.
Once notepad is launched, click on file then select ‘open’.
Navigate to the directory ‘C:/windows/system32/drivers/etc’ then change the file type to ‘all files’ at the bottom right corner of your notepad editor.
Once the host file appears double click on it to open it. Add the server names of your projects to the file and save it.
Now launch your projects by simply typing their server names as url e.g localhost.project1, etc.