WAMP Server Install: Difference between revisions

From vwiki
Jump to navigation Jump to search
m (Formatting and Meta)
m (→‎MySQL: Minor tweak to procedure)
 
Line 61: Line 61:


=== MySQL ===
=== MySQL ===
* <code> mysql-installer-5.5.23.0.msi </code>
* EG <code> mysql-installer-5.5.23.0.msi </code>
# Select '''Install MySQL Products''' and click '''Next'''
# Select '''Install MySQL Products''' and click '''Next'''
# Accept the GPL and click '''Next'''
# Accept the GPL and click '''Next'''
# Check for newer updates (if you have internet access)
# Check for newer updates (if you have internet access)
# Select the '''Custom''' setup type, and click '''Next'''
# Select the '''Custom''' setup type, update the installation path if you require, and click '''Next'''
#* Tick '''MySQL Server''' to install the core database components
#* Tick '''MySQL Server''' to install the core database components
#* Tick '''MySQL Workbench'' to install the GUI admin console (optional, can be installed on local desktop instead, if at all)
#* Tick '''MySQL Workbench'' to install the GUI admin console (optional, can be installed on local desktop instead, if at all)

Latest revision as of 09:11, 3 July 2012

Windows, Apache, MySQL and PHP (WAMP) install guide for a Windows 2008 64bit server.

For Windows, IIS, MySQL and PHP (WIMP) see http://blogs.iis.net/bills/archive/2006/09/19/How-to-install-PHP-on-IIS7-_2800_RC1_2900_.aspx

Whilst this guide intends to be as generic as possible, it is disingenuous to suggest that you can blindly follow the procedures below, for different versions of the software components than were used here, and expect it all to work. I have included the install package filenames that I used, which normally exactly identifies the variant and version I've used (Microsoft supplied packages are the exception, as they like to keep to guessing).

Installing LAMP takes seconds (well minutes), installing WAMP constantly reminds you that you're trying to fit a round peg into a square hole, and that it would probably be quicker and easier to learn Linux (its what made me first tinker with Ubuntu).

There are numerous install bundles that can supposedly do the job for you, they're always a little out of date, and none are endorsed by PHP. I'm not saying don't consider them, but just do it in a well thought out way.

Downloads

The following are required to complete an installation.

Apache

Don't download Apache from apache.org, these have not been compiled with the latest Microsoft Visual Studio compiler (VC10), and so do not have the improvements in stability and performance that that provide, and more importantly, are not compatible with the latest VC9 compiled PHP binaries (so will restrict you to older versions).

Download the latest required installers from http://www.apachelounge.com/download/

  • Apache 2.4 Win32 binary
    • EG httpd-2.4.2-win32.zip
  • PHP Handler (needs to be the right version for version of PHP)
    • EG php5apache2_4.dll-php-5.4-win32.zip

Prerequisites which also need to be downloaded...

PHP

Download the latest thread-safe ZIP package from http://windows.php.net/download/

  • PHP VC9 x86 Thread Safe
    • EG php-5.4.0-Win32-VC9-x86.zip

Prerequisites which also need to be downloaded...

MySQL

Download the compete package from http://www.mysql.com/downloads/installer/

  • MySQL Installer
    • EG mysql-installer-5.5.23.0.msi

Note that whilst the page states its a 32bit package, on installing the core MySQL Server will be 64bit.

Prerequisites which also need to be downloaded...

Installation

If installing on a Virtual Machine, take a Snapshot 1st, and maybe even at regular intervals once you're happy each component is properly installed.

This procedure assumes you already have a fully working Windows 2008 server, and will install software files to the C:\ drive, with data and website files being located on D:\.

Pre-Requisite Components

  1. Install Microsoft Visual C++ Redistributable Packages
    • vcredist_x86-2008.exe
    • vcredist_x86-2010.exe
  2. Install Microsoft .NET Framework 4.0
    • Either dotNetFx40_Client_setup.exe (donwloader)
    • Or dotNetFx40_Client_x86_x64.exe (full-fat installer)
  3. Perform a Windows Update to ensure all components are up to date

MySQL

  • EG mysql-installer-5.5.23.0.msi
  1. Select Install MySQL Products and click Next
  2. Accept the GPL and click Next
  3. Check for newer updates (if you have internet access)
  4. Select the Custom setup type, update the installation path if you require, and click Next
    • Tick MySQL Server to install the core database components
    • Tick 'MySQL Workbench to install the GUI admin console (optional, can be installed on local desktop instead, if at all)
    • Tick MySQL Connectors / Connector/NET to install the .NET connector (required for PowerShell support, PHP installs its own connector)
  5. Confirm pre-requisites are met and click Next
  6. Click Next for installation to complete
  7. Click Next to proceed with MySQL Server configuration to take place
    • Select Server Machine
    • Enable TCP/IP networking only if remote database connections are required (a remote MySQL Workbench session requires this)
    • Leave Create Windows Service checked
    • Enter a good root password
  8. Click Next and Finish to exit installer
  9. Move databases to seperate drive (optional)
    1. Create new folder
      • EG D:\MySQL\data
    2. Stop the database service, MySQL55
    3. Edit the config file C:\ProgramData\MySQL\MySQL Server 5.5\my.ini
    4. Change the datadir parameter appropriately
      • EG datadir="D:\MySQL\data\"
    5. Copy the contents of C:\ProgramData\MySQL\MySQL Server 5.5\data\ accross to D:\MySQL\data\
    6. Rename C:\ProgramData\MySQL\MySQL Server 5.5\data\ to C:\ProgramData\MySQL\MySQL Server 5.5\data-old\
    7. Start the database service
    8. Assuming the service starts, delete C:\ProgramData\MySQL\MySQL Server 5.5\data-old\

Apache

  • httpd-2.4.2-win32.zip
  1. Uncompress the file, and move the Apache24 folder to C:\Program Files (x86)\
  2. Create a folder for your web root, and copy across the C:\Program Files (x86)\Apache24\htdocs\index.html file
    • D:\Apache\htdocs
  3. Edit the C:\Program Files (x86)\Apache24\conf\http.conf and change
    • NOTE: Apache paths must use / as folder seperators, not \ !!
    • ServerRoot "C:/Program Files (x86)/Apache24"
    • ServerAdmin admin@domain.com (to something appropriate for your environment)
    • DocumentRoot "D:/Apache/htdocs"
    • <Directory "D:/Apache/htdocs"> (should match DocumentRoot directive)
  4. Install as a service, from a command prompt...
    • cd "c:\Program Files (x86)\Apache24\bin"
    • httpd.exe -k install
  5. You should now be able to browse to the server (http://yourserver), and get a basic "It works!" page back, in case of errors, double check your config file, and check the Windows Application log

PHP

  • php-5.4.0-Win32-VC9-x86.zip
  1. Uncompress the file, move the resultant folder to C:\Program Files (x86)\ , and rename to PHP
  2. Extract the php5apache2_4.dll file from php5apache2_4.dll-php-5.4-win32.zip and move to C:\Program Files (x86)\PHP\
  3. Rename C:\Program Files (x86)\PHP\php.ini-production to C:\Program Files (x86)\PHP\php.ini
  4. Update the PHP config (C:\Program Files (x86)\PHP\php.ini)
    • extension_dir = "C:\Program Files (x86)\PHP\ext"
    • date.timezone = Europe/London - use the appropriate location from http://php.net/date.timezone
  5. Update the Apache config (C:\Program Files (x86)\Apache24\conf\http.conf), add the following
    • # PHP Handler
    • LoadModule php5_module "C:/Program Files (x86)/PHP/php5apache2_4.dll"
    • AddHandler application/x-httpd-php .php
    • PHPIniDir "C:/Program Files (x86)/PHP"
  6. Restart the Apache, in case of errors, double check your config file, and check the Windows Application log

Testing and Troubleshooting

In order to test your install, you need 3 files in your D:\Apache\htdocs folder

  • index.html
    • Comes with Apache, copy across from C:/Program Files (x86)/Apache24/htdocs if it doesn't exist
  • phpinfo.php
    • Create the file, with the following single line contents: <?php phpinfo(); ?>
  • mysqltest.php


In each of the following tests there are really only two places to look for errors if they don't appear in the browser window...

  • Apache log - C:\Program Files (x86)\Apache24\logs\error.log
  • Windows System and Application Event Logs - Found in Server Manager | Diagnostics


  1. Browse to http://yourserver
    • You should get a basic It Works! page, this will confirm that Apache is installed and working
    • If not, check that the Apache service is started, and for any errors in the Windows System and Application event logs
  2. Browse to http://yourserver/phpinfo.php
    • You should get a page detailing the PHP install
      1. Check that that there is a section for mysql (not mysqlnd), which confirms that the MySQL module is being loaded. If not, in a Command prompt, cd to "C:\Program Files (x86)\PHP" and run php -m which will confirm which modules are being loaded, and hopefully an error as to why mysql isn't.
    • If not, check the Apache error log
  3. Browse to http://yourserver/mysqltest.php and enter the password for your MySQL root account
    • You should get a page listing the default databases
    • If not, check the MySQL service is started (if not check the Windows System Event Logs)