sitemap | search | contact me   

Developing and debugging your PHP and MySQL scripts on your local Windows Vista machine

This set of instructions will attempt to guide you through the installation of the latest Apache HTTP server software, the PHP scripting engine, the MySQL database and the MySQL administration tool phpMyAdmin on your local machine. It also explains how to create virtual local hosts in order to easily install or develop multiple websites, or versions thereof, simultaneously. This set up is tested for sites running the latest ecommerce software such as Magento and OSCommerce, and content management systems (CMS) such as Drupal and Joomla. It is not meant to be exhaustive, but it can be considered as a basis for further configuration. Lastly, it will explain how to set up and manage your website through Dreamweaver CS3's site management.

Taken together, this setup should provide a platform from which to develop, set up and debug websites locally from desktop or laptop with the aim of ultimately uploading to and synchronising with the remote production server.

Lastly, it should be noted that the server's security configuration as set up here is suited for local development ONLY and should NEVER be adopted for a production environment on a web server.

How to install the Apache HTTP server on Windows Vista for local development purposes

Prepare Windows Vista by displaying file extensions and (temporarily) disabling User Access Control. Here, it is assumed that no other versions of Apache HTTP Server software are currently installed on your system and that port 80 is available for requests. Browse to the Apache HTTP Server Project at Select a suitable mirror site and in the section identifying the best available version select 'other files'. Now look for and download the MSI installer package of this version by subsequently following the link to the binaries folder and the win32 folder. At the time of writing this version was 2.2.6 as released on 7 September 2007. The full package, called apache_2.2.6-win32-x86-no_ssl.msi, weighs in at 4.1 MB.

After the download, start up the installation wizard. After the welcome screen click next after reading and accepting the license agreement by selecting the correct radio button. Then, enter 'localhost' for both the network and server domain and for the email 'any'. Select install Apache for 'all users' as a service on port 80 and choose 'typical setup' as the set up type in the next screen and click install after leaving the destination folder as default. Several black command screen windows might temporarily come into view if all goes well.

Finish the installation wizard and confirm correct installation of the Apache Server software by entering 'localhost' in the address bar of your favorite browser. Secondly, check in the notification area of the Windows taskbar if the Apache Sevice Monitor is running. This monitor will enable you to quickly restart the Apache server after any configuration changes and also provide a quick way of opening the Windows Services management console. Check if the monitor is automatically started on system start up by looking for the Apache icon in the startup folder of the Windows start menu. If no shortcut is present prepare one linking to 'C:\Program Files\Apache Software Foundation\Apache2.2\bin\ApacheMonitor.exe'. Now restart your system and confirm that both the Apache HTTP Server and the Monitor are running.

The main Apache HTTP server configuration file 'httpd.conf' is kept in the 'conf' folder, whereas the server's error and log files are kept in the 'logs' folder. Both folders are found at the following location: C:\Program Files\Apache Software Foundation\Apache2.2.

Tip: in the next guides to installing PHP and MySQL take note of the forward and back slashes!

Installing and setting up PHP 5.2 on your local Apache HTTP development server

The Windows binary PHP 5.2 MSI package can be downloaded via your mirror of choice from The 19.3 MB 'PHP 5.2.5 installer' file was deposited on 15 November 2007. Again, temporarily disable Windows' User Access Control and start up the PHP installer. After the welcome window and agreeing to the end-user license agreement and the default installation folder select to setup PHP as an 'Apache 2.2.x module'. When asked to select the Apache configuration directory containing the httpd.conf file browse to 'C:\Program Files\Apache Software Foundation\Apache2.2\conf' and click OK.

In the next windows select the following non-core extensions to be installed on the local hard drive alongside the CLI executable programme: Curl, GD2, Mcrypt, Multi-Byte String, MySQL, MySQLi, PDO MySQL, SQLite and any other additional module of your interest or install those mirroring the production server. After finishing the setup wizard, restart your machine.

Next, open up Windows NotePad or Dreamweaver and in code view type

<?php phpinfo(); ?>

and save this test file as 'info.php' in the C:\Program Files\Apache Software Foundation\Apache2.2\htdocs folder. Open up your internet browser and enter 'http://localhost/info.php' in the URL, which should open the PHP info page.

In Dreamweaver open up the PHP configuration file php.ini located in C:\Program Files\PHP and look for the line containing 'display_errors = off'. For developing and debugging purposes change this to 'on'. In the same file change both the 'upload_tmp_dir' and the 'session.save_path' to 'C:\Windows\Temp'.

Subsequently, open the Apache server configuration file httpd.conf and change the 'DocumentRoot' around line 150 to 'C:/htdocs'. Then, around 25 lines further down find '<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">' and replace for '<Directory "C:/htdocs">'. If you want to override the configuration settings as set in httpd.conf in all files and folders contained in C:\htdocs using .htaccess files find 'AllowOverride None' within the '<Directory "C:/htdocs">' container and replace for 'AllowOverride All'. Next, enable loading of the Apache rewrite module by un-commenting '#LoadModule rewrite_module modules/'.

Around line 212 add 'index.htm index.php' to the 'DirectoryIndex' and now save both the PHP and Apache configuration files.

After creating the C:\htdocs folder, move info.php (see above) into this folder and rename this file to index.php. Restart the Apache web server using the Apache Service Monitor and enter 'http://localhost' in your browser, which again should open the PHP info page.

Tip: to install extra extensions, restart the PHP installer, choose 'Change installed features', add any additional module, finish the wizard and restart the server.

Setting up virtual hosts for local development on your Apache development server

Virtual hosts are registered in Windows in a file called 'hosts' found in the C:\Windows\System32\drivers\etc folder. Open this file in Dreamweaver and after the last line add ' vhost1', vhost1 being the example of a name for your new virtual server. Open the Apache configuration file and uncomment '#Include conf/extra/httpd-vhosts.conf' by removing the preceding hash/hex character. Doing so enables virtual hosting but also disables the default server root 'localhost'. In order to recreate the local host and the new virtual hosts open the virtual host configuration file httpd-vhosts.conf in the C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra folder and after deleting or commenting out the 'dummy1' and 'dummy2' host information enter the directives in the 'VirtualHost' containers as follows:

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  DocumentRoot "c:/htdocs/localhost"
  ServerName localhost
  ErrorLog " c:/htdocs/localhost.log"

<VirtualHost *:80>
  ServerAdmin webmaster@vhost1.vhost
  DocumentRoot "c:/htdocs/vhost1"
  ServerName vhost1
  ErrorLog "c:/htdocs/vhost1.log"

Create the 'localhost' and 'vhost1' folders in at c:\htdocs plus the error log files for both the local and virtual host. After restarting the Apache server test both hosts using the test file as done above.

Tip: create shortcuts to php.ini, httpd.conf, httpd-vhosts.conf and hosts files in the c:\htdocs folder to quickly access all configuration files!

Installing the MySQL database server software on Windows Vista for local development purposes

Browse to and after picking a mirror download the Windows Essential (x86) installer file. Version 5.0.45 was released on 7 July 2007 and the 23 MB download called mysql-essential-5.0.45-win32.msi. Version 5.1.0 should be available in early 2008. Open the MSI setup wizard for MySQL and choose a typical setup.

When finishing the wizard choose to configure the MySQL server, followed by selecting a 'detailed configuration', 'developer machine', 'non-transactional database only', 'decision support', enabling TCP/IP networking for communication with Apache and PHP scripts through 'port number 3306' and enabling 'strict mode', followed by the 'standard character set' and installing MySQL as a Windows service launching automatically at system start up thereby including the Windows 'bin' (binary) directory as path. Modify the security settings by choosing a new root password and leave 'enabling remote root access' and 'create an anonymous account' unchecked. Execute the configuration wizard and finish.

Tip: MySQL can be configured at any time by choosing the configuration wizard from the Windows start menu. The service can be stopped, started and restarted through the Microsoft services management console by right clicking on the Apache service monitor icon in the system tray and selecting 'open services'.

Installing phpMyAdmin:
The MySQL database administration tool

At download the English zip file of the latest version not denoted as a release candidate. Version was first distributed on 20 November 2007 and the zip file phpMyAdmin- counts 1.77 MB. Extract all files directly in the C:\htdocs\phpmyadmin folder.

Continue by creating a virtual host called 'phpmyadmin' as shown above and restarting the Apache server. In the C:\htdocs\phpmyadmin folder locate and duplicate this file as Open this file in Dreamweaver or a suitable text editor and comment out the single line below 'Authentication type' and add one line with your MySQL database password to read the following:

/* Authentication type */
// $cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['password'] = 'your-mysql-pwd';

A few lines further down find the line $cfg['Servers'][$i]['extension'] and change 'mysql' for 'mysqli' between the last quotes. Test your settings by browsing to 'http://phpmyadmin'.

Published on 12.12.2007 by Sjaak van der Sar   –   Leave critique or other comments