(ve):Install PHP-FPM on Ubuntu 10.04

  • This page was last modified on November 22, 2010, at 09:42.
The (mt) Community Wiki is a collaborative project. Any (mt) Media Temple customer or employee may contribute. Not all articles and/or content have been tested for accuracy by (mt) Media Temple.

For officially moderated and tested articles, be sure to visit our KnowledgeBase.

From (mt) Community Wiki

PHP-FPM (PHP FastCGI Process Management) is a patch for PHP to improve PHP’s FastCGI capabilities and administration. The most common option for those using Lighttpd or Nginx is spawn-fcgi, a library from Lighttpd to manage PHP processes. Although this works well in many respects, PHP-FPM offers a few additional benefits over spawn-fcgi:

1. Process Management. Using PHP-FPM provides the ability to gracefully stop and start PHP workers without losing any queries. You also have a log and pid file as well.

2. Restrict IP addresses from which requests can come from.

3. Start the workers with different uid/gid/chroot/environment and different php.ini option. You do not need a safe mode.

4. Just like MySQL, PHP-FPM provides the ability to track the slow execution of scripts and record them in a log file along with the backtrace.

This wiki will provide steps to install PHP 5.3.2 with FPM baked right in. Until PHP starts shipping with FPM, the easiest way of getting this set up is with a Launchpad PPA. If you’re working on a new (ve) server, we’ll only need 1 dependency met before we get started.

aptitude install python-software-properties

This package provides an abstraction of the used apt repositories. It allows you to easily manage your distribution and independent software vendor software sources. Since we’re going to be using a Launchpad PPA, we’ll need this tool to make adding packages easier. Personal Package Archives (PPA) allow you to upload Ubuntu source packages to be built and published as an apt repository by Launchpad. The one we’ll be using was brought to us by Brian Mercer.

add-apt-repository ppa:brianmercer/php

You should see some gpg output. This is normal. Now that we’ve added the new apt repository, we need to update our sources list:

aptitude -y update

Now, install the preferred PHP packages. These are simply examples that I frequently use. The one you’ll need for this is example is php5-fpm:

aptitude -y install php5-cli php5-common php5-mysql php5-suhosin php5-gd
aptitude -y install php5-fpm php5-cgi php-pear php5-memcache php-apc
service php5-fpm start


To check that PHP is listening on port 9000, run the following command:

netstat -ant | grep :9000

You should see something like this:

tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN