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

Mint LAMP Development Environment

OPERATING SYSTEM: Linux Mint 13 Maya

For Drupal development, since I already have a Linux Mint system setup, I decide to focus on it rather than the Windows 8 Acquia Drupal setup I blogged about a few days ago.

Apache, MySQL & PHP

Install all of these applications with a single command. Thanks to Unix System Engineer, Nitin Sookun for posting this on the Linux Mint Community website.

Since you will need root permissions when performing write operations outisde of your home directory, the commands shown below presume that you are logged in as root or are in a root instance of the terminal. If you are not in a root terminal, you can prepend the commands with ‘sudo’, for example listing the contents of the current directory:

sudo ls
Sudo Sandwich
Sandwich

In a root terminal (such as ‘Konsole as root’).

apt-get install lamp-server

If you get this error message (as I did during a Mint Xfce LAMP install)

E: Unable to locate package lamp-server

Then you will need a carat at the end:

apt-get install lamp-server^

Then install phpMyAdmin

apt-get install phpmyadmin

Restart Apache and try loading http://localhost/phpmyadmin.

/etc/init.d/apache2 restart

If phpMyAdmin doesn’t load, try adding an Include to your Apache config with a text editor (such as ‘Kate’). In your terminal, open a new bash shell tab, and launch the editor (gedit, kate, etc.)

kate /etc/apache2/apache2.conf

In the apache configuration file, near the bottom, look for the location of other Include statements and insert this phpmyadmin include as needed.

Include /etc/phpmyadmin/apache.conf
/etc/init.d/apache2 restart

mySQL

If you need to set or change the mySQL root password, use this command syntax when the password has not been set.

$ mysqladmin -u root password NEWPASSWORD

Use this command syntax to change the root password.

$ mysqladmin -u root -p'OLDPASSWORD' password 'NEWPASSWORD'

Drupal

Download the latest stable Drupal core distro from http://drupal.org/download. Extract the downloaded file, for example, drupal-7.19.tar.gz to the host root, /var/www. Then with the mv command, rename the drupal-7.19 directory extracted into www to drupal7

tar -xf drupal-7.19.tar.gz -C /var/www
mv /var/www/drupal-7.19 /var/www/drupal7

Copy the default.settings.php to settings.php. Then apply write permissions to both the dafault directory and the settings.php file so Drupal can modify settings.php as needed during the install.

cd /var/www/drupal7/sites
cp default/default.settings.php default/settings.php
chmod a+w default
chmod a+w default/settings.php

Note, after Drupal is installed, reset settings.php file permissions to read only using a-w

Virtual Hosts

Setting up some Virtual Hosts in our Apache config. In terminal, open the apache cofig file for editing (gedit, kate, etc.)

kate /etc/apache2/apache2.conf

Below the Files node, add this code block.

NameVirtualHost *:80

  ServerName default
  DocumentRoot /var/www/

  ServerName drupal7
  DocumentRoot /var/www/drupal7

  ServerName drupal8
  DocumentRoot /var/www/drupal8

Restart Apache to load our config changes

/etc/init.d/apache2 restart

Hosts file

Add the two named virtual hosts to the hosts file

kate /etc/hosts
127.0.1.7	drupal7
127.0.1.8	drupal8

Restart apache …

/etc/init.d/apache2 restart

Now you can access the new Drupal website at http://drupal7

Next – Mint LAMP Development Environment – Part Two

Resources