Using PHP on Windows vs Linux

This topic is particularly relevant to the article on how to install PHP on windows with IIS, but it's a question worth asking when deciding to deploy an application.

It's no secret that we at Anchor prefer Linux over Windows any day, and not just for web hosting. It's much easier to support and manage, and things are much more predictable. There's a reason why the "LAMP stack" (Linux + Apache + MySQL + PHP) got so popular; it just works! You can build an application with these components and reasonably expect to deploy it with a minimum of fuss at any hosting provider. A fresh installation of a Linux system is almost certain to include all of these components, working and ready to use immediately.

In contrast, PHP on Windows is not quite as smooth. Your choice of web server (usually Apache or IIS) will affect how you install PHP, and each choice has its own quirks. PHP+IIS is described in the article mentioned above, and it's by no means a trivial ride. Eschewing IIS means using Apache, another not-quite-native-to-Windows application, though it's fairly easy to get up and running.

In a way, the title of this article is deceptive. We'd argue that there's no choice to be made, and that you should always use Linux. Insofar as it concerns us, the quality of support we can give you for PHP on Linux is far better; a Good Thing. PHP was made for Linux, so it works best there. The only times to consider Windows is if part of your application uses something Windows-specific (eg. COM).

Considerations

Assuming you need to use Windows, what next?

IIS

  • IIS is included with Windows, so it should mostly "just work"
  • With IIS you can (easily enough) run PHP via ISAPI, FastCGI or CGI
  • It's the only choice if you also need to run .NET or other Windows-specific stuff
  • Can integrate access-control with Windows accounts
  • Limited mod_rewrite and proxypass support

Apache

  • Fairly easy to install
  • Uses mod_php, also easy enough to use CGI, and probably FastCGI
  • No ability to use ASP or other .NET stuff
  • Fully-functional mod_rewrite!
  • htaccess files for access control and tweaking
  • May be easier to support/deploy some applications