Debian/Ubuntu - PHP without Apache

on 2015-03-01

If you have ever tried to install PHP on a Debian (or Ubuntu) machine, you may notice that it also tries to pull down Apache as well.

This is great if you have actually planned to use Apache, but if you want to use another web server (e.g. nginx, lighttpd, etc), this is an unnecessary dependency.

You can, however, get around this by doing:

sudo apt-get install php5-fpm php5-cli php5

Under Debina/Ubuntu with APT, PHP has a hard dependency on either FPM or CGI versions of mod_php. As such, when attempting to install php5, apt will try and find the first available version of the php and install that one. This typically means you get Apache as well.

Specifying php5-fpm you can setup and configure PHP with your preferred webserver instead.