In this tutorial I will describe the process of configuring a PHP and MySQL server on a Windows computer with running the Apache Web Server version 2.2. This configuration is ideal for developing websites on your own computer, without the need for a server.
There are many other methods to achieve this, and it is not limited to running on Windows or Apache, however this is most common configuration for developers. There are many other guides available on the internet describing setting up PHP and MySQL on other configurations.
The procedure for installation will be:
- Installation of MySQL
- Installation of PHP
- Finalisation & Testing
You will need the following to be able to follow this tutorial successfully:
- Windows XP / Vista / 7
- Apache Web Server version 2.2, already set up and working (available to download from http://httpd.apache.org/)
- PHP Windows binary
- The version required for use with Apache 2.2 on Windows is VC6 x86 Thread Safe (2010-Jul-21 20:06:17)
- This is available to download from http://windows.php.net/download/
- About 45 minutes to spare
- It is worth disabling anti-virus during the installation, to avoid conflicts. Remember to re-enable it after installation is complete.
- The first step it to install MySQL onto your computer. To start run the file with the extension .msi
- Choose the typical installation option and click “Next”
- Now click the “Install” button
- Wait for the installation to complete, then opt to not register with the MySQL website
- Ensure that the option to start the MySQL Config Wizard is selected and click “Finish”.
- The MySQL Config Wizard will now open; press “Next” to proceed
- Select “Detailed Configuration” and click “Next”
- Now select “Developer Machine” if this is for developers, or “Server Machine” for servers, then press “Next”
- Select “Multifunctional Database” then click “Next”
- If “InnoDB Tablespace Settings” appears just click “Next”
- Select “Decision Support (DSS) / OLAP” and click “Next”
- Ensure that both “Enable TCP/IP Networking” and “Enable strict mode” are both selected, then click “Next”
- Select “Standard Character Set” for Western scripts (eg English, French, German) or “Bes t Support for Multilingualism” if you want to support different scripts (eg Arabic). Then click “Next”
- Ensure that “Install as Windows Service” is ticked then press “Next”
- This page is the security of the MySQL server. It is best to change the password for the root account, but make a note of it because it impossible to recover. Ensure that “enable root access from remote machines” is NOT ticked and “create an anonymous account” is also NOT ticked. Then click “Next”
- Now press “Execute”
You have now successfully installed MySQL.
- Run the PHP installer file
- Click “Next” on the welcome page
- Agree to the license agreement and click “Next”
- The default installation directory is fine, but you can change it here. When you’re happy with it, click “Next”
- Select “Apache 2.2.x Module” from the list of Web Servers, then click “Next”
- Click “Browse…” to navigate to the Apache Configuration Directory (by default C:\Program Files\Apache Software Foundation\Apache2.2\conf ), then click “Next”
- The default settings for the items to install are fine, but if you wish to install extras, such as PHP manual, extra extensions, you can do so here. Once you’re happy, click “Next”
- If you wish to review any settings, now click “Back”. If you’re happy, click “Next”
- The PHP installer will now install everything which takes one or two minutes on a modern computer
- Once complete you should see the following page. Click “Finish” to exit the installer.
Finalising & Testing
PHP & MySQL have both now been installed; however everything isn’t quite finished yet. You should now:
- Restart the Apache service. You can do this either:
Test that it has installed correctly
- Through the Start Menu: navigate to All Programs, Apache, Restart
- Through the Services application: Start, Run, type “services.msc”, find Apache2.2, right click and select “Restart”
- Restarting your computer
Remember to re-enable your anti-virus if you disabled it
- Do this by creating a page called test.php with the following text:
<?php phpinfo(); ?>
Then, open a web browser, browse to test.php on your server and request the page. You should see a page detailing your PHP configuration.
PHP & MySQL should now be successfully set up on your computer! Have fun with developing interactive web applications!
Detailed instruction on the installation of MySQL, along with screenshots, can be found at: