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:
... do not change this / default root block...
- Likewise, if you use SSL, update DocumentRoot “C:/xampp/htdocs”
- 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.
- Edit “c:\xampp\apache\conf\httpd.conf” and locate the <Directory “C:/projects”> block (or whatever path you had selected as document root).
- 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
Options Indexes FollowSymLinks Includes ExecCGI
Allow from all
- 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.'”>.
- 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.
- Go to Start, Control Panel, Windows Firewall and click on the Advanced tab.
- Make sure that “Local Area Connection” is checked and hit the Settings button to the right of it.
- Under Services tab, make sure that “Web Server (HTTP)” is checked.