Upgrading to PHP 5.3 - an easy way

I already talked about how WPI can help you installing PHP on Windows running IIS. If you haven't read that post, I would encourage you to read that post before continue reading this. The link is here. So wondering why I am asking you to read the previous post of mine. Well the reason is we are going to upgrade to PHP 5.3 following my previous post and then doing a little bit of trick. Again I have seen a lot of forum posting in the IIS forum where people have asked about this. I would again ensure that manual steps are extremely limited and that most of the process is done by the software.

If you already have any version of PHP running (greater than PHP5.2.8) with IIS FastCGI please ignore this paragraph. Otherwise install the latest version of PHP 5.2.11 using Microsoft Web Platform Installer as described in my previous blog. Once your PHP environment is set properly please follow the next paragraph. A quick and easy way to test the PHP installation is to write a small PHP script (name it anything you want, I am naming it index.php) and have <?php phpinfo() ?> as a content in the file. You can save this file in your WEBROOT folder and access it using browser of your choice.

In order to test PHP installation on IIS I generally do the below:

  • Go to DOCUMENT_ROOT (typically this will be C:\Inetpub\wwwroot) and create a folder named 'phptest'.
  • Save the above file with name index.php inside the folder 'phptest'.
  • Please ensure that you have a site named 'Default Web Site' present and the physical path is pointing to 'C:\Inetpub\wwwroot' and the port binding is default 80 port. When you enable/install IIS by default this is created so unless you have deleted it yourself, it should be there.
  • Now invoke Internet Explorer and type 'http://localhost/phptest/' in the address bar.
  • If you are able to see a proper page full with PHP information, you are all set.

If you would like to move to PHP5.3 now I would strongly advise to go through the migration guide at http://us.php.net/migration53. This details out all the differences. new features etc. Windows binaries for PHP5.3 are available at http://windows.php.net/download/. I would advise to do the following:

  • Understand thoroughly the need for PHP5.3
  • Go to Control Panel/Add Remove Programs and uninstall PHP5.2.11
  • Download the MSI for 5.3 from http://windows.php.net/download/. There are certain advantages of using the MSI as it automatically does some configuration setting for you. So I would suggest to use the MSI. Ensure that you are downloading the NTS version of PHP MSI. At a top level MSI will do the below things automatically if you have selected IIS FastCGI to be configured from the install UI:
    • Do the handler mapping for *.php files
    • Add 'index.php' to default document set
    • Set some of the INI directives for you in PHP.INI file which is considered as a good practice
  • At install time select all the extensions you would like to use.
  • Install PHP 5.3.
  • One of the changes in 5.3 is related to timezone where if PHP INI directive date.timezone is not set, PHP will issue you a warning. Please set it to something you would like the default to be to get rid of this warning in your PHP.INI file. A list of supported timezone can be found at http://us3.php.net/manual/en/timezones.php.

Hope this helps you run PHP5.3. And thanks for the patient reading.

Now that you know how to configure and test PHP installation under IIS, let us focus on some cool PHP programming tips. Next week I am planning to talk about writing a basic authentication page using PHP. Till then good bye.

Don Raman

9 Comments

  • do the handler mappings for *.php files?
    does this mean using php-cgi.exe? im lost...

  • Handler mapping for *.php means configuring PHP to run via FastCGI. Something like:
    ".php,C:\WINDOWS\system32\inetsrv\fcgiext.dll,5,GET,HEAD,POST"

    MSI does it automatically for you and you don't need to do it yourself. And please avoid trying to set it up manually. USe the MSI and you will be done.

  • well, completely failure on this upgrade for me - nothing seemed to work. First I realised that wincache would need upgrading so I removed it and reinstalled with the php 5.3 version. That didn't seem to make a difference. I setup a phpinfo() script and it runs fine - further investigation shows php5.3 can't connect to my mysql database. Googling around there's mention of problems with "old" style authentication - problem is this is a brand new mysql install with new user accounts.

    I'll try for a little longer, then it's back to 5.2 :(

  • Hi,

    PHP 5.3.1 has got some problems connecting to MySQL. If you are getting a connection timeout, please refer to the PHP bug at http://bugs.php.net/bug.php?id=50172. This talks about a solution to work it around.

    Hope this helps.

    Thanks,
    Don.

  • thanks Don, found that and uncommenting localhost in hosts (2008R2) fixed that problem.

    None of my joomla sites are working though, all are 1.5.15 which is supposed to work on php5.3 :(

  • Good to know that. Yes, Joomla has problems with PHP5.3.1. You will need to go to their forum and sort this out.

    Thanks,
    Don.

  • looks like joomla itself is OK, it's various 3rd party components using deprecated functions that are the problem - it's mostly been easy to fix even for a relative PHP neophyte like myself.

    I must say that php5.3 on 2008r2 with wincache feels like it's absolutely flying compared to php5.2 on 2003, which is what I'm migrating from.

    Only piece of the puzzle left is a PHP5.3 ioncube loader ...

  • Yes, wincache should give you nice performance. And you are correct there are lot of functionality deprecated which generates a lot of warning. It's a good idea to clean them up. This will ensure more compatibility of the application with PHP5.3. And in general 5.3 with Windows 2008 R2 and WINCACHE should be faster.

    Thanks,
    Don.

  • Hi,

    What do you see? You can do troubleshooting using my blog at http://blogs.iis.net/donraman/archive/2009/11/15/troubleshooting-php-installation-on-windows.aspx.

    Also it will be appropriate to post the question with details on http://forums.iis.net/1102.aspx.

    While posting please ensure that you have followed the above troubleshooting blog and paste the output of command mentioned in the blog and let me know the OS you are trying to install.

    Thanks,
    Don.

Comments have been disabled for this content.