Skip to content

Setting Up an Apache, MySQL, PHP Development Environment with XAMPP

Rather than installing Apache, MySQL, and PHP individually, XAMPP is an integrated development enironment that combines all three (and more) into one easy installation.

  • Download XAMPP and install it into the default “c:\xampp” directory. Set apache and mysql to start as services.
  • Start XAMPP and browse to “http://localhost/” and you will see a welcome message.
  • If you don’t want to use the default “c:\xampp\htdocs” directory as your document root, you can update the DocumentRoot “C:/xampp/htdocs” property and <Directory “C:/xampp/htdocs”> element in the “c:\xampp\apache\conf\httpd.conf” file. The result should look like:
    DocumentRoot "c:/projects"
    <Directory />
    ... do not change this / default root block...
    </Directory>
    <Directory "c:/projects">
    ...
  • Likewise, if you use SSL, update DocumentRoot “C:/xampp/htdocs”
    in “c:\xampp\apache\conf\extra\http-ssl.conf”.
  • Note: XAMPP uses the “c:\xampp\apache\bin\php.ini” when running PHP. There is a second “c:\xampp\php\php.ini” which is used if you call “c:\xampp\apache\bin\php.exe” from the command line.
  • Edit “c:\xampp\apache\bin\php.ini” to enable logging by setting the following properties:
    error_reporting = E_ALL
    log_errors = On
    error_log = "C:\xampp\apache\logs\phperror.log"
  • To enable access to the original XAMPP htdocs directory, we can create a subpath redirect to it using the alias function.
    1. Edit “c:\xampp\apache\conf\httpd.conf” and locate the <Directory “C:/projects”> block (or whatever path you had selected as document root).
    2. Immediately after the whole <Directory> block above (look for the matching end tag </Directory>), add the following text:
      # Allow access to the original xampp htdocs
      Alias /htdocs C:/xampp/htdocs
      <Directory "C:/xampp/htdocs">
          Options Indexes FollowSymLinks Includes ExecCGI
          AllowOverride All
          Order allow,deny
          Allow from all
      </Directory>
    3. Adjust the htdocs files to account for the base URL change:
      • Edit “c:\xampp\htdocs\index.php”, locate header(‘Location: ‘.$uri.’/xampp/’);, and change that to be header(‘Location: ‘.$uri.’/htdocs/xampp/’);.
      • Repeat the above for “c:\xampp\htdocs\xammp\index.php” and “c:\xampp\htdocs\xampp\lang.php”.
      • Edit “c:\xampp\htdocs\xampp\splash.php”, locate
        <a href=”/xampp/lang.php?’.$key.'”>
        , and change that to be <a href=”/htdocs/xampp/lang.php?’.$key.'”>.
    4. Start XAMPP, open your browser to “http://localhost/htdocs” and you will see the original xampp htdocs directory.
  • If you attempt to access Apache from another machine in your network and your brower returns an access error, you may need to adjust your Windows Firewall. The latest version of Windows Firewall forces you to manually open up ports for services.
    1. Go to Start, Control Panel, Windows Firewall and click on the Advanced tab.
    2. Make sure that “Local Area Connection” is checked and hit the Settings button to the right of it.
    3. Under Services tab, make sure that “Web Server (HTTP)” is checked.

2 Comments

  1. gracie

    cool! definitely will give that a try.

  2. php

    It is quit good post for PHP combination

Leave a Reply to php Cancel reply

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