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
- Install the latest version of the Apache HTTP server (currently 2.4.6).
- 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.
- 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.
- 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.
- 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).
- Update the configuration file.
- 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.
- 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).
- Change ServerAdmin to your email address.
- Uncomment the ServerName line and change it to your website address, or just localhost:80.
- Change DocumentRoot to “C:/Program Files/Apache/Apache 2.4/htdocs”
- Change the relevant <Directory line to “C:/Program Files/Apache/Apache 2.4/htdocs”
- Change the ScriptAlias line to “C:/Program Files/Apache/Apache 2.4/cgi-bin”
- Change the relevant <Directory line to “C:/Program Files/Apache/Apache 2.4/htdocs/cgi-bin”
- Save your changes.
- Install Apache as a service.
- 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.
- Install Apache as a service with the command httpd.exe -k install. There should be no errors reported there.
- Also start Apache with the command httpd.exe.
- 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.
- 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.
- Set the Apache Monitor to run on startup.
- Open File Explorer and type shell:startup in the address bar to get to the startup folder for the current user.
- Right click the white space and select New, then Shortcut.
- Select ApacheMonitor.exe from the C:\Program Files\Apache\Apache 2.4\bin folder, and finish creating the shortcut.
- 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
- 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.
- From the Welcome screen, select Install MySQL Products.
- 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.
- From the Feature Selection step choose your desired features.
- 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.
- Continue through the next steps, including the Installation step, until you get to the Configuration step.
- Leave most of the defaults, except check Show Advanced Options, and click Next.
- Set a MySQL root password and click Next.
- Walk through the next few steps leaving the default settings, until you are finished the installation.
- The MySQL Notifier should automatically be installed and should pop up a message saying that there is a new instance being monitored.
- 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.
- 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.
- 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.
- 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
- Download the the latest version of PHP (currently 5.5.3) from http://windows.php.net/download/.
- 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.
- 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).
- From the Windows Control Panel, under System and Security, then System, choose Advanced system settings to open the System Properties window.
- Switch to the Advanced tab, and click the Environment Variables… button at the bottom.
- 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.
- 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
- Click OK to close all these windows.
- 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.
- 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).
- Open Notepad (Run as administrator) and open C:\Program Files\Apache\Apache 2.4\conf\httpd.conf.
- 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”
- 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.
- Save the file.
- 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.
- Open the Apache Monitor from the system tray, and restart Apache.
- 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.
- 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.
- Enable MySQL support in PHP.
- Open Notepad (Run as administrator) and open C:\Program Files\PHP\PHP 5.5.3\php.ini.
- 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.
- 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
- Save the file, and restart Apache from the system tray.
- 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.
- 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(); ?>
- If you see the following page in your browser, you have successfully enabled MySQL support in PHP.
- Other recommended configuration changes
- 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.
- extension=php_curl.dll This extension allows PHP to access other websites.
- extension=php_gd2.dll This extension allows PHP to edit images.
- extension=php_exif.dll This extension allows PHP to access EXIF data within images.
- extension=php_openssl.dll This extension allows PHP to use OpenSSL for encrypting and decrypting data.
- extension=php_xsl.dll This extension is required by phpDocumentor, if you that is something that you use.
- 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.
- Make sure display_errors = On, display_startup_errors = On, and log_errors = On.
- 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.
- 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 - 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.
- Save the file and restart Apache from the system tray.
- 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.
Congratulations, your WAMP web server on Windows 8 is now installed.
Next
Comments are closed