Set up your PC as a test environment using Apache, PHP and MySQL

You can approach the set up of a test environment in 2 seperate ways. You can manually set up Apache/IIS, PHP and MySQL seperately then configure them to work together or you can use a package such as WAMP (Apache, MySQL, PHP) or XAMPP (Apache, MySQL, PHP, Perl).

There are benefits to manually setting up each bit of software for the purpose of the test server we will just use Xampp.

XAMPP Installation

Go to the XAMPP website and download the correct version for your operating system. Depending on your operating system the download can vary from ~20MB to ~100MB.

Windows users

Download page

Linux users

Download page

Mac OS X users

Download page

Download the Installer package and install using the instructions on the download page.

Once installation has finished, start Apache and MySQL and set up the admin password's to make it secure using the instructions on the download page.

XAMPP Configuration

First we need to change a few settings in Apache and PHP to make Drupal work a bit better.

Locate the directory you installed XAMPP to and open the apache folder, followed by the conf folder. Open up the httpd.conf file in your favourite plain text editor.

Around line number 118, you should see a line similar to the following:

#LoadModule rewrite_module modules/mod_rewrite.so

If you search for rewrite_module you should be able to find it. 

Change this to:

LoadModule rewrite_module modules/mod_rewrite.so

Make note that we have removed the hash (#) which commented out the line.  We need the rewrite module so that we can have friendly URLS such as http://www.domain.com/this/is/friendly rather than http://www.domain.com/?first=this&second=is&third=friendly.

Save and close the file, then location the php folder within the XAMPP directory. In this directory is a file called php.ini. Open this file in your favourite text editor.

Find the line (should be around line 246):

memory_limit = 32M      ; Maximum amount of memory a script may consume (16MB)

Change this to:

memory_limit = 96M      ; Maximum amount of memory a script may consume (16MB)

Also make sure safe_mode is set to Off.

safe_mode = Off

This should be around line 168.

Save and close the file. 

In the XAMPP control panel click the Stop button next to Apache and wait around 10-15 seconds. Then press Start. Go to http://localhost or http://127.0.01, if it loads up properly then we haven't broken anything yet.

XAMPP Testing

Back again in the XAMPP installation directory, create a folder called test. In this folder, create a file called index.php. In this file, type the following:

<?php print 'Hello World!!'?>

Now direct your browser to http://localhost/test/ or http://127.0.0.1/test/.

You should see the text:

Hello World!!

If so, success.  You have now set up XAMPP correctly to enable you to install most open source PHP software.

Comments

[...] If you do not have a webserver yet but wish to set up your personal computer as a testing environment, please read through and complete the following guide on Setting up your PC as a test environment using Apache, PHP and MySQL. [...]