How to Install PHP 5.3 on Windows

Tweet

PHP5.3 on WindowsWith all the excitement surrounding Firefox 3.5, it may have escaped your attention that PHP 5.3 has also been released. This is the most significant update since version 5.0 and several features that were originally scheduled for version 6.0 have been slipped into the build. You’ll be hearing about these on SitePoint soon but, first, we need to install PHP 5.3 on our Windows development systems.

A Word of Warning…

PHP 5.3 is new and you may experience some problems (see below). If you already have a stable PHP environment, ensure you keep a backup of your current php folder and settings.

Web Server Installation

If you have not installed Apache, refer to How to Install Apache Web Server on Windows. Optionally, you can also install the MySQL database — refer to How to Install MySQL.

PHP 5.3 Installation

Windows PHP distributions are now available from a dedicated microsite at http://windows.php.net/download/. The choice is a little bewildering and the instructions are vague but, since we will be installing PHP as an Apache 2.2 module using the Apache Lounge build, so you should download the VC9 x86 Thread Safe Zip file.

General note:
Download the VC6 builds if you are using the standard Apache.org web server. The VC9 builds should be used for the Apache Lounge binaries or IIS.

A Thread Safe version should be used if you install PHP as an Apache module. The Non Thread Safe version should be used if you install PHP as a CGI binary.

You can now follow the instructions at How to Install PHP on Windows from step 2 onwards. Note that, in step 3, php.ini-recommended is now named php.ini-development; you still need make a copy and rename it php.ini.

If you have previously defined a working PHP configuration file, a tool such as WinMerge can help you compare and copy existing values to your new php.ini file.

PHP 5.3 Error Reporting

The first time you load your previously bug-free PHP application, you are likely to be confronted by reams of long-winded error messages. Don’t panic! PHP 5.3 introduces a number of new error directives which are enabled by default in the development php.ini configuration:

  • E_STRICT suggests improvements that ensure best interoperability and forward compatibility of your code, and
  • E_DEPRECATED warns you about code that will not work in future versions of PHP.

Very useful. In my experience, the majority of messages report that a time zone has not been defined and assigning a return values using new by reference is deprecated.

Unfortunately, applications can display so many minor errors they become impossible to use. You can disable the new error directives by setting the error_reporting value to "E_ALL & ~E_DEPRECATED" on line 514 of php.ini and restarting Apache.

However, several web applications, including WordPress, define their own error_reporting settings and may continue to show messages. It will take a developers some time to upgrade their applications to full PHP 5.3 compatibility.

Have you installed PHP 5.3 successfully? Have you experienced any major issues or problems with existing code?

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • http://logicearth.wordpress.com logic_earth

    I’ve been running the alpha/beta/RCs of 5.3, made a full switch after the first VC9 compiled binaries were released. Yes I am using IIS, version 7 to be exact. I probably should make a tutorial for SitePoint on installing PHP for IIS 7. Cause you know Apache is not the only way.

    Oh…and I;ve mostly has successful installations. Only a few times have I had problems during the beta.

  • Pierre

    “The VC6 x86 Non Thread Safe version should be used if you intend installing PHP as an Apache CGI binary. The VC9 x86 Non Thread Safe version should be used if you intend installing PHP on IIS in FastCGI mode. Neither option is described here.”

    As long as you run something using fastcgi or cgi, you should use the VC9 builds. That means not only for IIS…

    It is critical to use the same crt with Apache (vc6 for apache.org’s binaries and vc9 for apachelounge.com’s binaries) as using different crt may cause random issues (crashes).

  • Anonymous

    That “windows” laptop is clearly a white macbook. hrm.

  • http://www.optimalworks.net/ Craig Buckler

    @Anonymous
    It’s running Parallels ;^)

  • Anonymous

    There is nothing PHP 5.3 specific about this post. PHP has been throwing timezone errors since the new ext/datetime extension was released by Derrick in v5.2 (I think). Scary to think that the recommended way to get your apps “working” is to suppress the error messages :(

  • http://www.optimalworks.net/ Craig Buckler

    @Pierre
    Thanks for the information. The instructions have been updated to make it clearer (I hope). However, for the record, I’ve tried both VC6 and VC9 Thread Safe versions as a module on the apachelounge.com binaries. Both work without problems … so far. Unfortunately, several people have reported problems on the forums.

    @logic_earth
    I will certainly consider further articles regarding PHP on IIS. I’d always recommend your development platform is similar to your host; if they provide IIS/PHP then you should use it. However, the majority of PHP developers use Apache.

    @Anonymous
    The specific PHP 5.3 information in this post regards the download (which is far more confusing) and the new error directives (which will certainly cause more grief than 5.2.x).

    I would recommend fixing errors rather than suppressing error messages. However, that is not practical if you are developing, say, a WordPress theme. Remember that you’re not suppressing everything — just minor (but long-winded) compatibility warnings.

  • PHP Newbie

    Hi Craig,

    Do you have this HOW-To for Windows 2003 Server with IIS? I am currently using PHP 5.2.10 on Windows 2003 Server with IIS using the ISAPI module. Here is the link http://www.iisadmin.co.uk/?p=4&page=1 that I use to follow to get my installation to work. With PHP 5.3 the ISAPI module is no longer available and I am at a lost in trying to get this new version to work. Any help would greatly appreciated.

    Thanks,

    PHP Newbie

  • http://www.optimalworks.net/ Craig Buckler

    @PHP Newbie
    Unfortunately, I don’t use Windows Server 2003 and I there are some differences with the Windows Pro version of IIS. I suggest posting a question in the SitePoint Forums … someone, somewhere will have solved the issues you’re having.

  • http://logicearth.wordpress.com logic_earth

    @PHP Newbie, The better way to run PHP on IIS is by using the new FastCGI module Microsoft made in partnership with Zend (Major contributor to PHP). There is a version for 5.1 (Windows XP) 6.0 (Server 2003) and 7.0 (Vista/Server 2008/Seven).

    More information can be found at the official IIS site.
    Using FastCGI to Host PHP…IIS 6.0

  • Blizzke

    Also, PHP seems to have issues with NTFS Sparse points (Junctions) since 5.2.9
    So people using those to “redirect” some of the content in their DocumentRoot (or for the errorlog) might come into a nasty surprise when trying to switch to 5.3
    I personally lost about 4 hours worth when I tried to install it.

  • ob duhhh

    i got php 5.3 and the apache from apachelounge.com VC9. done the steps. but on steps 2 in the reffered how to, there’s a php5apache2_2.dll. but the VC9 build has no such file.

    Comments….please…

  • http://www.optimalworks.net/ Craig Buckler

    @ob duhh
    php5apache2_2.dll is contained in the PHP download/folder. The Apache httpd.conf file just references it. Hope that helps – sorry if it wasn’t clear.

  • Anonymous

    ob duhhh is correct. The VC9 builds do not include the mentioned DLL. If you find out where to find it (I didn’t so far) let me know.

  • Blizzke

    @Craig: ob duhh is correct. The VC9 versions of the PHP distributable do not include php5apache2_2.dll. I have been looking for the file myself, unsuccessful so far. Unless I completely overlooked it…

  • http://www.optimalworks.net/ Craig Buckler

    Have you downloaded php-5.3.0-Win32-VC9-x86.zip? The dll is there in my copy?

  • Blizzke

    I did. Perhaps I was to fast with my download after the 5.3 release. I just re-downloaded it and the file is present in the zip (as you said). My apologies.