How To Install Php 5.4 With Apache 2.2

  

This tutorial just updated version of my previous one.This time we are going to install newer version of apache (httpd 2.4), PHP 5.4 but as a PHP-FPM.Instructions are pretty simple.

Mar 17, 2012

How install Apache 2.4 PHP 5.4 and MySQL 5.5.21 on Windows 7

Recently decided to install a working Apache 2.4 / PHP 5.4.9 and MySQL 5.5 running locally on my Windows 7 laptop for web design, not using XAMPP or WAMP installation methods. Which are great but this round I wanted to match my Linux server.

Apache 2.4 Install

First download Apache 2.4 from http://www.apachelounge.com/download/ (httpd-2.4.1-win32.zip) Apache 2.4.1
with IPv6 apr-1.4.6 apr-util-1.4.1 apr-iconv-1.2.1 pcre-8.21 lua-5.1 libxml2-2.7.8 openssl-1.0.0g zlib-1.2.6. This release is supported by the PHP 5.4 install from windows.php.net for Apache 2.4.

Extract the zip and copy it to the root of C:. This will be C:Apache24 when it is all done.

How

Update 01-17-2013: The version of the php5apache2_4.dll must match the version of PHP you are installing. The link that was reference before has been changed and moved to http://www.apachelounge.com/download/additional/ for versions 5.4.9 and earlier. As of PHP 5.4.10 the module is now included in the Windows build.

PHP 5.4.9 and Earlier

How To Install Php 5.4 On Centos

Download PHP 5.4.9 VC9 x86 Thread Safe from http://windows.php.net/download/releases/archives/php-5.4.9-Win32-VC9-x86.zip . Extract and rename folder to php and move to C:
Also, download php5apache2_4.dll-php-5.4-win32.zip (http://www.apachelounge.com/download/win32/modules-2.4/php5apache2_4.dll-php-5.4-win32.zip)
Runs with PHP 5.4 Thread Safe (TS), and only with Apache 2.4 Win32 VC9 or VC10.

PHP 5.4.10 and higher

Download PHP 5.4 VC9 x86 Thread Safe from http://windows.php.net/download/ . Extract and rename folder to php and move to C:.

Update 01-17-2013: This next edit seems to cause issues with php5apache2_4.dll not found errors, so I have added two options for PHP 5.4.9 and earlier and PHP 5.4.10 and above. I want to thank all those who have brought this to my attention and I hope this helps out. Also, due to the addition of the php5apache2_4.dll being included in PHP 5.4.10 and above builds you no longer need to download the module separately.

PHP 5.4.9 and earlier Option 1

Extract php5apache2_4.dll-php-5.4-win32.zip and copy php5apache2_4.dll to the c:php directory. This is needed to allow Apache to use PHP. Edit Apache’s config file, c:Apache24confhttpd.conf and add the following lines to the bottom of the file.

2
PHPIniDir'C:/php'

While we are at it we can add index.php to Apache’s list just incase we want to have a starting page as php.

Find Directory index and add index.php

Next we need to input a value for ServerName variable. You will have to un-comment it. Save the changes to the config file. Next move to the Register Apache Service step.

PHP 5.4.9 and earlier Option 2

Extract php5apache2_4.dll-php-5.4-win32.zip and copy php5apache2_4.dll to the c:phpext directory. This is needed to allow Apache to use PHP. Edit Apache’s config file, c:Apache24confhttpd.conf and add the following lines to the bottom of the file.

2
PHPIniDir'C:/php'

While we are at it we can add index.php to Apache’s list just incase we want to have a starting page as php.

Find Directory index and add index.php

Next we need to input a value for ServerName variable. You will have to un-comment it. Save the changes to the config file. Next move to the Register Apache Service step.

PHP 5.4.10 and newer

Edit Apache’s config file, c:Apache24confhttpd.conf and add the following lines to the bottom of the file.

2
PHPIniDir'C:/php'

While we are at it we can add index.php to Apache’s list just incase we want to have a starting page as php.

Find Directory index and add index.php

Next we need to input a value for ServerName variable. You will have to un-comment it. Save the changes to the config file. Next move to the Register Apache Service step.

Register Apache Service

Now let’s register Apache as a service. Open a command prompt and type.

If do not want Apache starting automatically at start-up/reboot:

GUI Way

  • START | RUN
  • Type in services.msc, hit Enter or click OK
  • Locate Apache2 service and double-click (or right-click for Properties)
  • Find the caption Startup type: (in the middle of the dialog box), use the pull-down and select Manual
  • Click OK

Command line

Add

How To Install Php 5.4

to PATH in Environment variables. PATH ENVIRONMENT (System Properties | Advanced | Environment Variables | System variables | Path).
Example:
;c:php;c:apache24;c:apache24bin;

Now lets check Apache settings by issuing the command, c:Apache24binhttpd -S

PHP Edits

Now we have to do a few edits to the php.ini file to tell it to load support for mysql and the location for the extensions. Since there is not a already set php.ini file we need to rename one of the two examples to php.ini.

Rename c:phpphp.ini-development to php.ini

Now let’s edit php.ini
Uncomment extension directory.