XAMPP Windows Setup

Documenting my XAMPP for Windows setup for myself and anyone else who finds it useful. For those of you that do not know, XAMPP is a completely free, easy to install Apache distribution containing MySQL, PHP, and Perl. I still have my Virtual Machine for LAMP Development which I will use for test deployments of my localhost LAMP development prior to production deployment. This local XAMPP setup will be better for debugging, working with node modules and grunt tasks for preparing the deployment build.

XAMPP Configuration

Since my Windows 8.1 system is already using port 80 for IIS, I decided to setup XAMMP to use port 8080.

C:\xampp\apache\conf\httpd.conf
# on or near line 58
# change listen to 8080
Listen 8080

# on or near line 219
ServerName localhost:8080
C:\xampp\apache\conf\extra\httpd-vhosts.conf
# virtual hosts
NameVirtualHost *:8080

<VirtualHost *:8080>
  DocumentRoot C:/xampp/htdocs
  ServerName localhost
</VirtualHost>

# For htaccess rewrites to work AllowOverride
# needs to be set to All instead of None
<VirtualHost *:8080>
  DocumentRoot "C:/xampp/htdocs/mysite"
  ServerName mysite.dev
  ServerAlias www.mysite.dev
  SetEnv APPLICATION_ENV development
  <Directory "C:/xampp/htdocs/mysite">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

If you want to use a localhost tunneling solution such as pagekite to access your virtual host, change the ServerAlias to the URL your localhost tunneling provider has enabled. For example mysite.pagekite.me

C:\xampp\apache\conf\extra\httpd-vhosts.conf
# pagekite.me server alias
<VirtualHost *:8080>
  DocumentRoot "C:/xampp/htdocs/mysite"
  ServerName mysite.dev
  ServerAlias mysite.pagekite.me
  SetEnv APPLICATION_ENV development
  <Directory "C:/xampp/htdocs/mysite">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
C:\xampp\xampp-control.ini
# add to bottom so when
# control panel starts there
# are not Apache port errors
[ServicePorts]
Apache=8080
C:\Windows\System32\drivers\etc\hosts
# port numbers not allowed
127.0.0.1   localhost
127.0.0.1   mysite.dev

PHP Configuration

C:\xampp\php\php.ini
# enable PHP short open tags
short_open_tag=On

# development only
max_execution_time = 0

# XDebug
# uncomment these lines
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"

I use NetBeans for PHP development and prefer not having XDEBUG_SESSION_START=netbeans-xdebug querystring tacked onto my URL’s in order to debug.

C:\xampp\php\php.ini
# more xdebug settings
xdebug.remote_autostart = 1
xdebug.idekey = "netbeans-xdebug"

After starting up Apache in the XAMPP Control Panel, loading the site in the browser is now as easy as http://mysite.dev:8080/

XAMPP Windows Update

If you want to install a new version of XAMPP, the installer will not allow you to install over an existing copy. Follow these steps to:

  • backup the existing XAMPP installation
  • install the new version of XAMPP
  • copy config and mysql data into the new version
  1. Launch the XAMPP control panel and Stop all services.
  2. Quit the control panel
  3. Rename the installation folder, for example, change it from C:\xampp to C:\xampp_orig
  4. Create a new folder with the same name as the original installation. For example C:\xampp
  5. Install the new version of XAMPP
  6. Copy your website folders from *C:\xampp_orig\htdocs* to **C:\xampp\htdocs**. Do not copy xampp and other folders that are installed with xampp, such as dashboard and webalizer.
  7. Copy any changes you made to C:\xampp_orig\apache\conf\httpd.conf and C:\xampp_orig\apache\conf\extra\httpd-vhosts.conf into the new versions of these apache configuration files.
  8. Create databases with the same names as before. A new folder for each database will be created along with its respective db.opt file.
  9. Copy C:\xampp_orig\mysql\data\ibdata1 to C:\xampp\mysql\data\ibdata1
  10. Copy all of the files except for db.opt from each database folder in **C:\xampp_orig\mysql\data\* to **C:\xampp\mysql\data\*. Make sure you do not copy the db.opt file(s).
  11. Launch XAMPP control panel and start apache and mysql

Part 1 of 2 in the XAMPP Windows Setup series.

XAMPP Windows Setup SSL

comments powered by Disqus