Local server on XAMPP

October 24, 2019

Time to read: 2 min

Let's imagine you are working on website based on PHP and GIT and you need to open it on local server to test website. So far you have only FTP server of your website. It is a little bit time-consuming to upload every time you make changes.

In following post I will describe how to set a local server on XAMPP.

Let's assume you download XAMPP from official website and clone your directory to computer.

1 step:

You need to add your local domain of your website (hereinafter the WEBSITENAME). In order to do it you need to go to C:\Windows\System32\drivers\etc, open hosts file and add:

// in hosts      local.WEBSITENAME.com

2 step:

You need to update XAMPP v-hosts config file. Go to C:\xampp\apache\conf\extra\ and insert following code in httpd-vhosts.conf:

// in httpd-vhosts.conf

        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order Deny,Allow
        Allow from all
        Require all granted

<VirtualHost local.WEBSITENAME.com:80>
    php_admin_value include_path "PATH_TO_CLONED_WEBSITE_DIRECTORY\WEBSITENAME.com"
     ServerAdmin postmaster@dummy-host2.localhost
     ServerName local.WEBSITENAME.com
     ServerAlias local.WEBSITENAME.com
     ##ErrorLog "logs/local.WEBSITENAME.com"
    # ##CustomLog "logs/local.WEBSITENAME.com"

3 step:

Make change of prepend and append in .htaccess file of cloned directory in PATH_TO_CLONED_WEBSITE_DIRECTORY\WEBSITENAME.com

// in .htaccess
php_value auto_prepend_file "include/prepend.php"
php_value auto_append_file "include/append.php"

4 step:

Next changes are in php.ini file of XAMPP Apache config.

  1. Open xampp-control.exe and go to
  2. In Apache line click on Config
  3. Open PHP.ini
  4. Uncomment extension=soap
  5. Optional: To ignore php errors find display_errors=Off and set to display_errors=On

5 step:

You need to skip .htaccess file from updating every time you pull or push directory to GIT because you changed it in step 3.

You need to follow to PATH_TO_CLONED_WEBSITE_DIRECTORY\WEBSITENAME.com and skipp .htaccess

git update-index --skip-worktree .htaccess

That's it! Congrats!

So now you can restart XAMPP and go to browser you use and type local.WEBSITENAME.com in address bar. It should open you local repository of your cloned website. Happy hacking!

Hosted by NetlifyPowered by Gatsby