Looking over the referrer stats, it seems that many people reach this blog through Google searches more or less aligned with “How do I install PHP on IIS?”. I think XAMPP might be a better, and easier answer for many about to embark on a frustrating journey.
I can appreciate the need to install PHP under IIS for some purposes. For instance you need your application to co-exist in an environment where you are subject to the existing infrastructure, ranging to the more rudimentary “It’s what the client wants” concerns.
For the most part, I think we can all agree that few, if any visitors to this page would actually be building a web server to be deploy in a data-centre for production/mission critical purposes. I’d hazard that the vast majority of these visits are more interested in learning about PHP, dealing with configuration mysteries or just want a sane development environment in which to code, debug and test.
While the more modern Windows versions of PHP (5.2+) are easier to install and configure, PHP still feels handicapped, slow and clunky. ISAPI vs CGI, subjectively, ISAPI seems a bit more responsive but more prone to “space-outs”. The “space-outs” can be induced by developer error, say a loop was saved with no exit condition… or a long IO operation, just about all the stupid stuff developers do sometimes while approaching a problem. It’s not always the developer tho… but that’s a whole other rant that’s just plain ugly. Recovering these space-outs is a nuisance. The sure fire method is to kill it via the NET STOP W3SVC (or IISADMIN) and restart it in the same NET START W3SVC. Sometimes this works, other times, IIS needs to be killed via the Task-Manager. “Space-outs” in CGI mode are easily dealt with by killing the php-cgi.exe process with the Task-Manager, and life goes on.
In some cases, I’ve even come in after Microsoft “Patch Tuesday” and found the ISAPI install of PHP to be rightly violated and left in a completely unusable form. This is not a good way to spend a morning, mucking about in the damned IIS Administrator to try and figure out what got ‘wanged’.
The point of this is simple, yes, IIS ships with Windows XP and yes, it has a graphical administrator, but unless you have an explicit reason for needing IIS, I recommend that you don’t.
If you want to learn about PHP, or are a developer looking for a quick and easy way of getting productive in PHP, without the need for IIS: XAMPP is for YOU.
Though the name sounds and looks like some sort of a Winamp plug-in, don’t been fooled. XAMPP is a product by “Apache Friends” which is a non-profit project to promote the Apache web server. XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. XAMPP is really very easy to install and to use - just download, extract and start. The download can be obtained here.
This has everything you need to get a development environment up, and is vastly easier than configuring each package independently. Prior to installation, it’s recommended that you stop and disable IIS otherwise a port conflict will occur when Apache tries to start.
Beware, XAMPP is NOT for PRODUCTION PURPOSES out of the box. The security is deliberately loose, as not to create development roadblocks. I’m sure with some basic security hardening and tuning XAMPP would be a great workhorse.
Windows Cheat Sheet:
URL: http://localhost or http://127.0.0.1 or http://[whateveryourmachinenameis]
Default path: C:\XAMPP
“wwwroot”: C:\xampp\htdocs
PHP.INI: 2 Spots
- C:\xampp\php for command-line based PHP - AND -
- C:\xampp\apache\bin for Apache
MySQL: The defaults are a tad on the conservative side and probably fine for most purposes. Like all MySQL installations, it employs MyISAM tables by default. I require InnoDB tables for our application so I modify the my.cnf file found in C:\xampp\mysql\bin. It’s really a matter of just uncommenting the innodb section and adding a default_table_type = INNODB under the [mysqld] section.
Apache: Out of the box, you probably won’t need to do anything to it. It just works! Predictably, httpd.conf is found in C:\xampp\apache\conf
I’ve been running it both at home and at the office and frankly, it’s nice because I don’t have to do ANYTHING to it. I simply installed it, configured it, setup both MySQL & Apache as Services from the XAMPP Control Panel and got to work coding.
Really.
That was it and I haven’t looked back. It never crashes, the configuration never mysteriously changes, and PHP ALWAYS works. Using XAMPP under Windows will save you time and frustration.
- Paul