When I went to write the third edition of my PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide book, I had to decide what version of PHP to support. PHP5 had been out some time and PHP6 was more than 50% ready to go. The primary alteration in PHP6 is support for Unicode, a change that Ruby is also making in version 1.9. This is a big deal, so I thought I’d include support for PHP6 in the book. Now, just over a year later, there’s no news on PHP6 and, from what I gathered, there’s not a pressing drive to get it out anytime soon, either. Such are the potential problems when it comes to writing about open source software: you really never know what you’re going to get or when. Obviously the situation isn’t ideal but only two chapters in the book require PHP6, and some features originally intended for PHP6 have been added to PHP5. Still, some users reading the book (rightfully) want to test or play with the forthcoming, primarily Unicode-related, features I discuss in those two chapters. In order to do so, you’ll need to do what I did in order to write the book: install a beta version of PHP6 on your computer. In this post, I’ll walk you through that process for Windows users (I’ll address non-Windows users separately).No matter what version of PHP you’re using, you need to run it through a Web server (unless you’re using it for command-line purposes only). Normally I would run PHP through Apache, even on Windows. Generally I advise beginning Windows users to install something like XAMPP, which is an easy, no-nonsense all-in-one packager for PHP, Apache, MySQL and more. So as not to have the PHP6 installation conflict or harm any existing PHP setups, I would recommend using another Web server for PHP6. In this example, I’ll use Abyss, from Aprelium, a nice, simple to use, lightweight alternative to Apache. You can also use Internet Information Services (IIS), the Microsoft Web server, but I’m much less familiar with it.
To start, download a snapshot of PHP6. A snapshot, in case you’re not familiar with it, is just a reflection of the software at a moment in time. For example, a snapshot may be what PHP6 looks like at February 17, 2009 at midnight. Note that snapshots are not intended for production use. Most PHP snapshots are at http://snaps.php.net. For Windows, you need to head to http://windows.php.net/snapshots/. As I write this, that page has snapshots available for three versions of PHP: 5.2, 5.3, and 6.0. For Windows running Apache or Abyss, you want to download the file named PHP 6.0 – Windows x86 VC6 (thread safe). The downloaded file is a ZIP that needs to be extracted. I extracted all of my files into a newly created C:\php6 directory.
Next you need to download and install Abyss. For this article, I used version X1, which is free. The Abyss installation process is really simple and needs no further explanation from me (check the official documentation if you have questions). After you’ve installed Abyss, start it up and you can configure it for PHP. Much of this information comes from Abyss’ own documentation for installing PHP, but with my own images (click the appropriate links to see them). After you register and login, you’ll be brought to the Abyss Web Server Console. Click “Configure” for the default host (note that your default host may run on a port other than 80 if you have another Web server installed). On the resulting page, click on “Scripting Parameters”.
On the Scripting Parameters page, make sure that “Enable Scripts Execution” is checked. Then click “Add” in the “Interpreters” table. This will take you to a new page. On that page, set the “Interface” to “FastCGI (Local – Pipes)”. Then click Browse next to the “Interpreter” and select the php-cgi.exe file in the extracted PHP6 snapshot folder. Don’t select the php.exe or php-win.exe file, use php-cgi.exe, which is explicitly for FastCGI usage. Change the “Type” to “PHP Style” and make sure the “Use the associated extensions to automatically update the Script Paths” box is checked. Click “Add” in the “Associated Extensions” table. In the popup window, enter php and click OK. This last step associates files with a .php extension wtih the PHP6 executable. (As an aside, if you wanted to use Abyss for multiple versions of PHP, you could associate .php with a PHP5 executable but .php6 for PHP6.) Then click OK to leave the Interpreters page. This will return you to the “Scripting Parameters” page.
Back on the “Scripting Parameters” page, click “Add” in the “Custom Environment Variables” table. In the resulting window, type REDIRECT_STATUS as the “Name” and 200 as the “Value”, then click OK. You’ll need to click “OK” on the “Script Parameters” page, which will take you back to the Abyss Web Server Console page. There, if you want, use the “Index Files” page to add index.php as an acceptable index file. Then, restart Abyss.
After you do all this, you can use a phpinfo() script to confirm the version of PHP that you now have running. And that’s it! Enjoy playing with PHP6 and let me know if you have any questions or problems (issues related to installation can be made as comments here; other questions should go in the book forums).