Setting up an Apache/PHP/MySQL development environment in Windows

php-mysql
The following instructions outline the steps required to setup an environment without having to use WAMP.  There are many ways to setup an environment, but I have settled on the following steps.  Leave a comment if you have questions or want to point out corrections.

Prerequisite Downloads

Installation Steps

MySQL

The MySQL install is very straightforward since it has an MSI.

  1. Run the installer.
  2. During the Configuration utilize the default options ( Development Machine, Port 3306, Open Firewall ).
  3. Provide a root password.  You don’t have create additional users.  You can do that from the command line later or via the MySQL Workbench ( additional software product  http://dev.mysql.com/downloads/workbench/ ) that provides you with a GUI interface to MySQL.
  4. Utilize the default service settings.  ( MySQL56, start MySQL at startup, use system account).  You can change this later via the Administration Tools -> Services and elect to manual start it if you want.
  5. NOTE: If you need to make changes to the MySQL server settings, you do this by editing the my.ini file located in ( C:\ProgramData\MySQL\MySQL Server 5.6 ).  Do not try to place this file in the Program Files directory.

Apache

The Apache process requires extracting files and updating the configuration file.  Though we could walk through creating different configuration files, moving the root directory and creating vhost entries, this tutorial will keep all the configuration within the main configuration file and will not create any vhost entries.

Extract Apache to a location on your drive.  I have elected to extract the files to c:\userapps\apache-2.4.9

The next few steps require editing the httpd.conf file located in <install dir>\Apache24\conf

  1. Change all occurrences of “c:/Apache24” with <install dir>/Apache24 ( e.g. c:/userapps/apache-2.4.9/Apache24 ).  NOTE the forward slash ‘/’, not a backslash ‘\’.
  2. Because it is required by applications such as WordPress, uncomment the mod_rewrite.so module. ( about line 153 ).  Do this by removing the # character at the beginning of the line.
  3. To cut down on startup messages, change the ServerName value to
    ServerName www.mylocalmachine.com 
    Make sure the # has been removed from the beginning of the line.
  4. Now we need to create a service in windows.  Launch a CMD prompt as an Administrator.  Navigate to <install path>/Apache24/bin directory.  Use the following command to create the Apache Service: httpd.exe -k install -n “Apache2.4”  ( If you get an error saying MSVCR110.dll is missing, which was a problem on an older Windows 7 machine, then you need to download and install the MVC C++ 2012 Redistributable package update 4 ).
    1. If you need to install the Redistribution packages, make sure you install both the x86 and x64.  These are downloaded as two separate files.
  5. Now start the service via Administration Tools -> Services or by entering the following in the CMD window:
    net start “Apache2.4
  6. Validate Apache is working by opening a browser and going to
    http://localhost
    and validating that you get the message “It Works!”

PHP

The PHP process requires extracting files and updating both the PHP and Apache configuration file.

Extract PHP to a location on your drive.  I have elected to extract the files to C:\userapps\php-5.5.14

Edit the httpd.conf file that we edited above.

  1. Add the following lines to the httpd.conf
    LoadModule php5_module “<intstall path>/php5apache2_4.dll”
    AddHandler application/x-httpd-php .php
    # configure the path to php.ini
    PHPIniDir “<intstall path>”

     

    Example:
    LoadModule php5_module “C:/userapps/php-5.5.14/php5apache2_4.dll”
    AddHandler application/x-httpd-php .php
    # configure the path to php.ini
    PHPIniDir “C:/userapps/php-5.5.14”

  2. Create a file called test.php in the Apache root directory ( <install path>/Apache24/htdocs ) with the following contents:
    <?php phpinfo(); ?>
  3. Restart Apache ( you can use the Administration Tools -> Services panel to do this )
  4. Load the test page using your browser and going to
    http://localhost/test.php
    Validate you get the “PHP Version 5.5.14” header and all the other PHP information about the server.

Now we are close but need to edit the php.ini file located in <install path> ( e.g. c:/userapps/php-5.5.14 ).  We need to edit this file in order to load some common PHP extensions for accessing MySQL, creating graphics (GD2), fetching web resources ( CURL ), etc.

  1. Copy php.ini-development to php.ini
  2. Uncomment ;extension_dir = “ext” and provide a fully qualified path to the ext directory.  When done it should look like:
    extension_dir = “<install path>/ext”
    Example:
    extension_dir = “c:/userapps/php-5.5.14/ext”
  3. Uncomment the following extensions:
    extension=php_bz2.dll
    extension=php_curl.dll
    extension=php_fileinfo.dll
    extension=php_gd2.dll
    extension=php_mysql.dll
    extension=php_mysqli.dll
    extension=php_pdo_mysql.dll
  4. Restart Apache ( you can use the Administration Tools -> Services panel to do this )
  5. Load the test page using your browser and going to
    http://localhost/test.php
    Validate that the GD module and CURL module are both present in the test page output.