Tuesday, December 5, 2006

Fast install latest Apache, PHP and MySQL on Windows

The easiest way to install a WAMP (Windows, Apache, MySQL) suite is by using a pre-built package like WAMPServer. However there are some situations this approach will not work: maybe you need a PHP version released today or maybe you need a specific version of MySQL. You can always install these packages separately and it will take you no more then 10 minutes if you know the steps. I will present you the process for the latest versions available today.

1. Download the packages

2. Apache installation
  • Start apache_2.2.3-win32-x86-no_ssl.msi from your downloads folder
  • Click "Next" until you get to the "Server Information" dialog. Usually default settings will be ok so click "Next" again.
  • Choose "Custom" install and click "Next"
  • I usually choose a different folder for the server like "C:\Server\Apache\". This will help later when you will edit configuration files. Choose the path and click "Next" then "Install".
  • Open a browser and enter "http://localhost/" in the address field to see if all went well.

3. PHP Installation
  • Unzip your downloaded file (php-5.2.0-Win32.zip) to a folder (I will use "C:\Server\PHP\")
  • Rename php.ini-recommended from PHP folder to php.ini
  • Open Apache configuration file (httpd.conf) from "C:\Server\Apache\conf\" and add 3 lines at the end (replace "C:/Server/PHP" if needed):
    PHPIniDir "C:\Server\PHP\"
    LoadModule php5_module "C:/Server/PHP/php5apache2_2.dll"
    AddType application/x-httpd-php .php
  • Click "Start > Run..." and enter "net stop apache2.2" to stop apache service
  • Click "Start > Run..." and enter "net start apache2.2" to restart apache service (this is needed to reload configuration file)
  • Now create a file called test.php in your web root folder (in our case "C:\Server\Apache\htdocs\") . The contents of the file should be:
  • Open a browser and enter "http://localhost/test.php" in the address field to see if all went well.

4. MySQL installation
  • Start mysql-essential-5.0.27-win32.msi from you downloads folder
  • Click "Next" and choose "Custom" installation type
  • Leave the default options selected and change the install folder if you want (I will use "C:\Server\MySQL\")
  • Choose "Next" then "Install"
  • I choose to skip registration but you may use it if you want
  • Make sure you let "Configure the MySQL Server now" checked before you click "Finish"
  • In the Server Instance Configuration Wizard click "Next" and chose "Detailed Configuration".
  • In the next screen I advise you to choose "Developer Machine" unless you plan to use this for a server.
  • Choose "Multifunctional Database" next.
  • Leave the default options for the "InnoDB Tablespace Settings" and click "Next";
  • Choose OLAP on the following page.
  • You can now click "Next" until you get to "Security Settings" page. Type a root password and write it down or make sure you will remember it.
  • Choose "Next" and then "Execute" to apply these settings.
  • To enable MySQL support for your PHP installation edit php.ini and uncomment (remove ;) the following line : extension=php_mysql.dll and modify the extension_dir parameter (to extension_dir = "c:\server\php\ext")
  • Apache needs a restart now so use "net stop apache2.2", "net start apache2.2" commands
  • All should be ready to go!
This is a simple procedure but I often get into trouble with it because I forget to set something. So I'll also use this when needed. I hope it helps!

2 comments:

Anonymous said...

Aside from the mentioned wampserver, there are other distributions, such as the Web-Developer Server Suite.

Sometimes its just simpler to get a built and configured setup, as it will save you time and effort. Try adding mod_aspdotnet and Tomcat/mod_jk and you will know what I'm talking about.

Anonymous said...

Whery good.

A litle repare:
Remember that the content of the test.php file is:

\<\?php infophp(); \?\>

and nothing more