Windows

If you’re running Windows, it’s not easy to compile PHP, and you’re probably already using PHP 4 as a CGI. Here’s how to integrate a precompiled version of PHP 5 into an existing Apache setup:

  1. Download and install a precompiled Windows zip package.

  2. Configure your web server to handle PHP 5.

  3. Set an alternative php.ini location.

If you’re using another web server, you will need to modify the configuration directions.

The first step is downloading and unzipping PHP 5. You can download Windows zip packages from http://www.php.net/downloads.php. (Be sure to grab the “zip” package instead of the installer.)

After you unzip the package, move it to a directory that is similar to your existing PHP 4 installation. On many systems, PHP 4 is at C:/PHP/, so these instructions place PHP 5 in C:/PHP5/.

Copy php.ini-recommended to php.ini and keep it in C:/PHP5/. Your pre-existing php.ini file is already located in someplace like C:/WINNT/, but you’re not ready to overwrite it yet. Make whatever server-specific customizations you need to the new php.ini file.

Now you need to modify your web server configuration file to handle PHP 5. If you’re running PHP 4 as a CGI, you should already have these three lines:

ScriptAlias /php/ "C:/PHP/"
Action application/x-httpd-php /php/php.exe
AddType application/x-httpd-php .php

This makes the file located at /php/php.exe under the document root execute files ending in .php. The ScriptAlias directive links this location to C:/PHP/php.exe on ...

Get Upgrading to PHP 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.