Vanadium Vanadium

web design

WAMP Part 1 – installation

Leave a Comment

This is the first part of a 4 part series on WAMP setup and configuration. Part 1 is a newer version of the original WAMP setup post that includes the following versions of the software in the stack.

  • Windows 8 Pro
  • Apache 2.4.6
  • MySQL Community Server 5.6.13
  • PHP 5.5.3

Windows 8

I am starting with a fresh install of Windows 8 Pro, and UAC (User Account Control) left on (the default setting).

Apache

  1. Install the latest version of the Apache HTTP server (currently 2.4.6).
    1. The MSI installer is the easiest way to install Apache, but the latest version that the Apache site links to is 2.2.25, httpd-2.2.25-win32-x86-openssl-0.9.8y.msi, available at http://httpd.apache.org/download.cgi. Follow the prompts and it will ask you for the necessary information, and install itself as a service on your computer. Then skip to the testing section below.
    2. If you want the latest version, binary installers for version 2.4.6 (for both 32 bit and 64 bit computers), are available from http://www.apachelounge.com/download/. I will be using the 64 bit version, httpd-2.4.6-win64-VC11.zip.
      1. As noted on the Apache Lounge site, if you don’t already have it installed, you will need to install the Visual C++ Redistributable for Visual Studio 2012 Update 3 (aka VC11) from http://www.microsoft.com/en-ca/download/details.aspx?id=30679. You will have to reboot after installing this.
      2. Download and open httpd-2.4.6-win64-VC11.zip and extract the contents of the Apache24 folder to your computer. I like to keep all programs inside my Program Files folder, so I created a folder at C:\Program Files\Apache\Apache 2.4 and extracted the files there (the use of spaces in the folder name is just fine).
      3. Update the configuration file.
        1. Open Notepad (you will have to right click it and Run as administrator to be allowed to save the file) and open C:\Program Files\Apache\Apache 2.4\conf\httpd.conf.
        2. Change ServerRoot to “C:/Program Files/Apache/Apache 2.4” (note that it requires Unix style forward slashes, not Windows style back slashes between folders).
        3. Change ServerAdmin to your email address.
        4. Uncomment the ServerName line and change it to your website address, or just localhost:80.
        5. Change DocumentRoot to “C:/Program Files/Apache/Apache 2.4/htdocs”
        6. Change the relevant <Directory line to “C:/Program Files/Apache/Apache 2.4/htdocs”
        7. Change the ScriptAlias line to “C:/Program Files/Apache/Apache 2.4/cgi-bin”
        8. Change the relevant <Directory line to “C:/Program Files/Apache/Apache 2.4/htdocs/cgi-bin”
        9. Save your changes.
      4. Install Apache as a service.
        1. Open the command prompt (you will have to right click it and Run as administrator for the necessary permissions), and change to the bin folder with the command CD C:\Program Files\Apache\Apache 2.4\bin.
        2. Install Apache as a service with the command httpd.exe -k install. There should be no errors reported there.
        3. Also start Apache with the command httpd.exe.
          1. These instructions can be found at http://httpd.apache.org/docs/2.4/platform/windows.html. The page also contains the command for uninstalling the service, httpd.exe -k uninstall. This page is mentioned in the INSTALL.txt file inside the C:\Program Files\Apache\Apache 2.4\ folder.
  2. Test Apache by opening a browser and browsing to localhost, or 127.0.0.1. If you get the following message, you have successfully installed Apache. image14
  3. Set the Apache Monitor to run on startup.
    1. Open File Explorer and type shell:startup in the address bar to get to the startup folder for the current user.
    2. Right click the white space and select New, then Shortcut. image09
    3. Select ApacheMonitor.exe from the C:\Program Files\Apache\Apache 2.4\bin folder, and finish creating the shortcut. image10
    4. Double click the shortcut to start the Apache Monitor for the first time. Uncheck Always ask before opening this file, if necessary. This adds an icon to the system tray so you can always see if the service is running, and where you can right click to stop or restart it.

MySQL

  1. Download the MSI installer for the latest version of the MySQL community server (currently 5.6.13) from http://dev.mysql.com/downloads/mysql/ and run it.
    1. From the Welcome screen, select Install MySQL Products.
    2. Walk through the next few steps, until you get to Choosing a Setup Type, where I will select Custom, and leave the Installation Path and Data path with their default locations.
    3. From the Feature Selection step choose your desired features.
      1. Under Applications, I unselect MySQL for Excel 1.1.1, and under MySQL Connectors, I unselect all of the options except the Connector/ODBC 525. I also unselect the Documentation, since I always use the online documentation. Basically, I like to install the Server, the Workbench, the Notifier, and the Utilities, although only the Server is required.
    4. Continue through the next steps, including the Installation step, until you get to the Configuration step.
      1. Leave most of the defaults, except check Show Advanced Options, and click Next.
      2. Set a MySQL root password and click Next.
      3. Walk through the next few steps leaving the default settings, until you are finished the installation.
    5. The MySQL Notifier should automatically be installed and should pop up a message saying that there is a new instance being monitored.
    6. If you left the option checked to “Run MySQL Workbench” in the last step, then try it out and see if you can connect to your server with your root password to see if MySQL is running correctly.
    7. In File Explorer, browse to C:\Program Files\MySQL\MySQL Server 5.6 and duplicate the file my-default.ini and rename it to my.ini. This allows you to change settings here, and allows the MySQL Workbench to save changes to settings as well. Right click the MySQL notifier icon in the system tray icon and restart the server.
      image24
    8. Right click the MySQL notifier icon again and select Configure Instance… to open up MySQL Workbench.  In the Navigator pane on the left, select Options file near the bottom, and then select the Networking tab. I like to change max_allowed_packet from 4M to at least 128M, as my programs often use the database for file storage. I know there’s some debate regarding whether or not this is a good practice, but this at least gives you the option to store larger files in the database, which require large packets to be sent to the MySQL server. Apply the new setting.
      image25
  2. In addition to MySQL Workbench, I recommend HeidiSQL or PHPMyAdmin for managing MySQL data, but I won’t explain the installation of those tools here.

PHP

  1. Download the the latest version of PHP (currently 5.5.3) from http://windows.php.net/download/.
    1. Click Windows 5.5.3 binaries and source, and download the .zip file for VC11 x64 Thread Safe. This release is currently experimental, but should be good enough for a development server.
    2. Like Apache, I like to keep PHP inside my Program Files folder, and I like to have separate folders for different versions, so I can switch between them if necessary. Create a folder at C:\Program Files\PHP\PHP 5.5.3, and extract the contents of the php-5.5.3-Win32-VC11-x64.zip to this folder (although some sites recommend against it, the use of spaces in folder names is just fine for this server configuration).
  2. From the Windows Control Panel, under System and Security, then System, choose Advanced system settings to open the System Properties window. image11
  3. Switch to the Advanced tab, and click the Environment Variables… button at the bottom. image12
  4. At the bottom of the Environment Variables window, in the System variables section, scroll down to find the Path variable, and click the Edit… button. image13
  5. In the Edit System Variable window, edit the Variable value field, adding two new items to the end, both the path to your PHP installation, and the path to the extensions folder of your PHP installation, separated by semicolons. ;C:\Program Files\PHP\PHP 5.5.3;C:\Program Files\PHP\PHP 5.5.3\ext
    1. Click OK to close all these windows.
  6. Open Notepad (again, you may have to right click it and Run as administrator to be allowed to save the file) and open C:\Program Files\PHP\PHP 5.5.3\php.ini-production or C:\Program Files\PHP\PHP 5.5.3\php.ini-development (I will choose the production version) and Save As… php.ini in the same folder.
  7. Configure Apache to run PHP (these instructions are taken from http://www.php.net/manual/en/install.windows.php, and then select Apache 2.x on Microsoft Windows).
    1. Open Notepad (Run as administrator) and open C:\Program Files\Apache\Apache 2.4\conf\httpd.conf.
    2. Below the existing #LoadModule lines, add the following lines (again, note the Unix style forward slashes in the path): LoadModule php5_module “C:/Program Files/PHP/PHP 5.5.3/php5apache2_4.dll” AddType application/x-httpd-php .php PHPIniDir “C:/Program Files/PHP/PHP 5.5.3”
    3. Scroll down to the DirectoryIndex line (inside an <IfModule dir_module> block) and change it from DirectoryIndex index.html to DirectoryIndex index.php index.html. This will make sure index.php pages are served when directory requests are made.
    4. Save the file.
    5. With Notepad still open, create a new file with only one line: <?php phpinfo(); ?> Save this file as index.php in the C:\Program Files\Apache\Apache 2.4\htdocs folder. We will use this file to test the PHP installation.
    6. Open the Apache Monitor from the system tray, and restart Apache. image15
    7. The status line at the bottom of the Apache Monitor window should now show PHP/5.5.3. You may have to close and re-open the Apache Monitor before the status line will update itself to show the PHP module. image16
  8. Test PHP by opening a browser and browsing to localhost/index.php, or 127.0.0.1/index.php (the file that you created earlier). If you get the following page, you have successfully installed PHP. image17
  9. Enable MySQL support in PHP.
    1. Open Notepad (Run as administrator) and open C:\Program Files\PHP\PHP 5.5.3\php.ini.
    2. Scroll down to the Paths and Directories section (about a third of the way through the file), and uncomment the Windows extension_dir line, so it looks like this: extension_dir = “ext” This will tell PHP where to look for extension files.
    3. Next, scroll down to the the Dynamic Extensions section (about half way through the file), and uncomment the following two lines to enable the mysql extension, and the mysqli extension (mysqli is the recommended API to use when for connecting to a MySQL database, the i stands for improved). Delete the semicolon to uncomment the lines. extension=php_mysql.dll extension=php_mysqli.dll
    4. Save the file, and restart Apache from the system tray.
    5. Open http://localhost/index.php in a browser again, and you should now see two sections that weren’t there before (about halfway through the page), a mysql section, and a mysqli section.
      image18
    6. Test your installation by editing your index.php file to something like this, using the “root” account, and the password you selected when installing MySQL: <?php $mysqli = new mysqli("localhost","root","password"); if($mysqli->connect_error) {     die("Connect error (".$mysqli->connect_errno."): ".$mysqli->connect_error); } print("Success: ".$mysqli->host_info); $mysqli->close(); ?>
    7. If you see the following page in your browser, you have successfully enabled MySQL support in PHP.
      image19
  10. Other recommended configuration changes
    1. There are a few other PHP extensions that are commonly used. To enable them, uncomment the following lines in the Dynamic Extensions section of the php.ini file.
      1. extension=php_curl.dll This extension allows PHP to access other websites.
      2. extension=php_gd2.dll This extension allows PHP to edit images.
      3. extension=php_exif.dll This extension allows PHP to access EXIF data within images.
      4. extension=php_openssl.dll This extension allows PHP to use OpenSSL for encrypting and decrypting data.
      5. extension=php_xsl.dll This extension is required by phpDocumentor, if you that is something that you use.
    2. If you are running this on a development machine, scroll up to the Error handling and logging section, and make sure that error_reporting = E_ALL, to show all errors.
    3. Make sure display_errors = On, display_startup_errors = On, and log_errors = On.
    4. Uncomment the error_log = syslog line so that PHP errors can be logged to the Windows Event Viewer (search for “Event Viewer” in the Start menu). Errors will appear under Windows Logs, Application.
      image20
    5. Uncomment the ;date.timezone = line under the [Date] section, and add a default timezone from one of the lists found at http://www.php.net/manual/en/timezones.php. This isn’t required to run PHP, but some web applications like ZenCart require a default timezone.
      date.timezone = America/Edmonton
    6. Lastly, scroll down to the File Uploads section, and change the upload_max_filesize = 2M to at least 8M, to allow larger file uploads. I usually set it to 128M.
    7. Save the file and restart Apache from the system tray.

Congratulations, your WAMP web server on Windows 8 is now installed.

Next

 

Leave a Reply

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