Installing Apache, PHP, and MySQL on your computer

If you want to start developing websites, you should set up a development environment on your local machine (computer) so you can work offline before making your websites live online.  This also means you can work on your websites even when you’re not online, which is kind of convenient if you’re traveling or don’t have a good internet connection.  It’s faster than working online (every time you make a change you have to connect to the website through the internet, as opposed to making a change on your local machine and just connecting to your machine).   Also, if you already have a website up and running (a production website) you can try making changes the website on an installation of that website on your local machine before making those changes live to the universe.  I’ve been learning about developing websites for the last year, and getting a development environment on my computer has been great.  The last few times I’ve had to set it up I’ve gotten help from much more technical people, but this time I bit the bullet and did it all by myself.  I hope these instructions can help even the most non-technical person.

These instructions are broken down into 3 main installations:

  1. Download and install Apache
  2. Download and install PHP
  3. Download and install MySQL

A lot of people call this a WAMP setup (Windows, Apache, Mysql, Php) – but for non-nerds like me I wouldn’t know to search for that as a keyword.   All I know is that I want to be able to develop Drupal websites on my computer before launching them on the web. I know you can use XAMPP which is all of these things rolled into one big ball of software, but I had some issues with XAMPP so I figured out how to do the separate installations myself.

Before running any installations, you should decide where you want all of your web stuff to go.  I have found it easiest to put everything (Apache, PHP) in a c:/dev/ folder.  But you can put it wherever you want – you’ll just need to make sure you make the appropriate adjustments for your file paths in the next steps.  You’ll also need some sort of text editor – I use PSPad – free and open source and works great for this stuff.

Apache installation:

  1. Go to to download the latest version of Apache, an open source web server.  When I was first learning this stuff, I thought a ‘web server’ was the actual computer that served out websites to the internet, but ‘web server’ also refers to the software that delivers content to the internet.   You will need this software if you want to direct your browser to your local machine, or ‘localhost’ and have it give you a web-y response.
  2. Download the most recent non-beta or non-alpha version (beta and alpha often refer to software still under development, so it may have some bugs).  As of writing this article, it is version 2.2.17 (released 2010-10-19).  You’ll see that for this version there are several different types of downloads available.  I chose httpd-2.2.17-win32-x86-no_ssl.msi.  (For developing on your own machine, you probably won’t need SSL (secure socket layer)).
  3. Once it downloads if you double click on it an installation wizard will open.  Tell the dumb Windows warning that you trust the source and you’re sure you want to run the program.
  4. Click Next to tell it to start the installation and next to accept the licence agreements.
  5. Apache Install Screenshot 1

  6. Enter localhost for the network name and server name, and enter in your email address.
  7. On the next screen tell it to a typical installation.  We’re not getting fancy here.
  8. When you get to the installation location, click the Change button to set the path for the installation.  Remember, we’re installing into c:/dev.  Navigate to c:/dev and then type in Apache2.2 for the installtion folder name.  Hit OK once you’ve got the path right, and then Next to start the installation.

  9. On the next screen, hit Install to start the installation.  Some black and white prompt windows might flash open and shut while it’s installing – just wait till it’s done installing.
  10. When it’s done you’ll click Finish to exit the installation.
  11. If you go into your Windows Explorer, you’ll see that you now have all sorts of files in your c:/dev/Apache2.2 folder.
  12. Once you’re finished with the installation, go to your web browser and type ‘localhost’ as your URL into your browser (not  You should see a message that says ‘It works!’  You’ll also see a little feather with a green arrow in your status bar that should tell you Apache is running.

PHP installation:

  1. Go to to download PHP.  This is the language that many content management systems (Drupal, Joomla, WordPress) use to build their systems.  For Drupal 6 (which is what I’m working with until Drupal 7 is released) you should use PHP 5.2.14 – Drupal 6 works fine with PHP 5.3, but some of the extensions for Drupal 6 don’t like PHP 5.3, so to be on the safe side I used 5.2 which will play nicely with all of Drupal’s extensions.
  2. You don’t want to get the complete source code for PHP – this is for super nerds doing PHP development or something like that (I made this mistake before).  You want to get the Windows Binaries – I chose PHP 5.2.14 zip package.  This is not an installation wizard like we used for Apache, since I had problems with the installer for PHP.
  3. Download and unzip the package (you’ll first be directed to a mirror site for the download, just pick anywhere close-ish).  Copy all of the contents of the unzipped folder into a folder named ‘php’ that you put in your c:/dev folder.  So your files should look like this now: c:/dev/php/all sorts of php junk
  4. You’ll now need to tell Apache where php lives on your computer.  Make a copy of your httpd.conf file in c:/dev/Apache2.2/conf/ and save it as httpd.conf.bak.  Windows will complain about this, but tell it it’s ok.  We’re making a backup of this file so we can also start over again if our changes to the file break things.  Now open up your httpd.conf file (using your text editor like PSPad) and add the following text to the bottom of the file and then save the file.  This is telling Apache where to find php, it is very important that the path to the PHPIniDir is correct.
    LoadModule php5_module “C:/dev/php/php5apache2_2.dll”AddHandler application/x-httpd-php .php# configure the path to php.ini

    PHPIniDir “C:/dev/php”

  5. To check to see if your php installation worked, make a file called phpinfo.php, and (using your text editor like PSPad) paste the following text into the file: <?php phpinfo(); ?>    Once you’ve done this, go to localhost/phpinfo.php in your web browser and you should get a bunch of info about your php installation that looks like this:
  6. We’ll also need to make some modifications to the php.ini file as well (to get our system to work with content management systems). This file is found in c:/dev/php.  Make a copy of the php.ini-recommended file, and rename it php.ini .  
  7. Open up the php.ini file with your text editor, and make the following changes (use the search function in your text editor to find them):
    display_errors = Off - change to display_errors = On
    ;error_log = filename
    – change to error_log = “c:\dev\php\PHP-ERROR-LOG.txt” (very important that you delete that semicolon at the front!)
    extension_dir = “./” – change to extension_dir = “c:/dev/php/ext”
    Go to the list of extensions and delete the semicolons in front of extension=php_mysql.dll and extension=php_mysqli.dll
    ;date.timezone = change to date.timezone =  “US/Central” (again be sure to remove the semicolon)
    ;session.save_path = “/tmp” – change to session.save_path = “c:\dev\php\temp” (remove the semicolon)

    Save your changes.

I hope you’re still with me. If things aren’t working as I’ve described, one thing to try first is to restart your Apache server.  You can do this by clicking on the little red arrow in your status bar (at the bottom of your screen), click on Apache, and then Restart.

MySQL Installation

  1. Go to to get the MySQL stuff.  This is open source database software, and is where most of the content and all of the settings you’ll make in your CMS are stored.  We’re going to get two things here – the server (database software) and workbench (this is how you access the database and get your CMS up and running).   I’m using a PC with windows 7 so I’m taking the 64 bit version for the server – if you have an older version of windows I think you’ll need the 32 bit version but I’m not making any promises about this.
  2. Download the MySQL Community Server software installation wizard from and the MySQL Workbench software at  I clicked on links to download MSI installers to get the following two files: mysql-essential-5.1.53-winx64.msi and mysql-workbench-gpl-5.2.30-win32.msi.  You will first be directed to a mirror site to download the files – I picked the HTTP sites rather than FTP.
  3. Once the files have downloaded, double click on the mysql-essential.msi file to start the installation.  (I don’t know if it matters what order you do this in).  Again, tell Windows to chill with the constant security warning, and run the installation wizard.
  4. Click Next to get to the first installation screen, and select the Typical installation.  Tell it to proceed with the installation.
  5. You’ll have to click next a couple a couple of times though screens telling you about SQL.
  6. When the wizard is complete, you’ll be presented with a window that has has ‘Configure the SQL server’ checked off – click Finish to run the configuration.
  7. You’ll now be presented with a series of MySQL Server Instance Configuration Wizard windows (the next part might be minimized to your task bar, you might need to click on the small tool icon in the toolbar to bring up the wizard.  Click Next to get started.
  8. In the next two screens, select Detailed Configuration, and then Developer Machine.
  9. On the next screen, you’ll have 3 choices.  Select Multifunctional Database and hit next.
  10. On the next screen it will ask you where you want to install the InnoDB datafile.  Just leave it as the standard settings and hit next.
  11. On the next screen leave the standard selection, Decision Support, selected and hit next.
  12. Leave the settings for networking options both selected, and hit next.
  13. Leave Standard Character Set selected, and hit next.
  14. Leave Install as Windows Service selected.  If you want to run things from the command line, select Include Bin Directory in Windows Path option on this screen as well.  If you have no idea what ‘run things from the command line’ means don’t worry about this option.
  15. You’re now going to set the security options.  It is very important that you remember your password here and save it in a safe place.  When the next screen says Ready to Execute, click the Execute button.  Click Finish when it’s done.
  16. OK, so we’ve installed the MySQL Server software, we now need to install the MySQL Workbench software.
  17. Run the MySQL-workbench.msi file you dowloaded with the MySQL-essential installer.
  18. Click next once the Setup wizard opens to get to the Setup type screen.  Select Complete and hit Next, then hit Install, and lastly hit Finish when it’s done.
  19. The MySQL Workbench software will open up automatically (if not, find it in your programs and open it to make sure it opens correctly.  You should see a screen like this:
  20. We now need to check to make sure our SQL installation works and is playing nicely with PHP and Apache.  In your c:/dev/apache2.2/htdocs folder, make a new file called mysqltest.php.
  21. While you’re there, deleted the index.html file that was there that let you know that Apache was working.  If this file stays there, you will always see ‘It works!’ when you go to localhost – we want to be able to see any files and folders that are in localhost instead.  Open up the mysqltest.php file with your text editor, and paste in the following text:
    mysql_connect(“localhost”, “admin”, “1admin”) or die(mysql_error());
    echo “Connected to MySQL<br />”;
  22. Now edit this file to contain the username and password you used when you set up MySQL.  Edit “admin” to be the default username “root” and edit “1admin” to contain your password.  This is whatever you entered in the security part of the MySQL setup.
  23. Go to localhost.  You should now see an index of files and folders, including phptest.php, and mysqltest.php.  If you still see ‘It works!’ you should make sure you deleted the index.html file and then refresh your browser (F5 for Firefox).
  24. Click on the mysqltest.php link, and you should see a message that says ‘Connected to MySQL’.  If you get an error, make sure you have the username (root) and your password entered correctly in the mysqlinfo.php file.  You could also try restarting your Apache server. Sweet!  You’re all set up.

In my next post I’ll talk about how to configure MySQL to set up Joomla and Drupal websites using the tools we’ve installed.

2 thoughts on “Installing Apache, PHP, and MySQL on your computer

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>