Install Nginx with PHP 5.3.3 (PHP-FPM) on Ubuntu 10.10

Post to Twitter

Today I’ll go over the steps of how to get PHP-FPM and Nginx working together on Ubuntu 10.10. I used this article as my starting point and made some minor modifications of my own.

To start with I used a clean version of Ubuntu 10.10 (Desktop). Adjust if needed for Ubuntu Server but the steps should really work the same with the exception you most likely won’t be running a browser on Ubuntu Server.

The first step is to update and install Aptitude if you don’t have it already. From there I’ll install Nginx and get it running.

$ sudo apt-get update
$ sudo apt-get install aptitude
$ sudo aptitude install nginx
$ sudo /etc/init.d/nginx start

Open a browser to this address and verify Nginx is working.

Next I’ll install PHP-FPM:

$ sudo aptitude install php5-fpm

Note: The configuration file for Nginx is located at: /etc/nginx/nginx.conf

Now we need to edit the vhost file:

$ sudo pico /etc/nginx/sites-available/default

Use the following screenshots to see what I’ve done.


(This is Optional)

Now take this section:

…and modify it to look like this (remove the comment blocks, add a space between include and the fastcgi_params, add in the /var/www)

Save the file and exit pico (or whatever editor your using).

Next we can add some PHP modules (modify as you wish) and create an info.php file to test with.

$ sudo aptitude install php5-cgi php5-dev php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ps php5-pspell php5-recode php5-snmp php5-tidy php5-xmlrpc php5-xsl php5-common php5-mysql
$ sudo pico /var/www/info.php

The contents of php.info as as follows:

<?php
	phpinfo();
?>

Restart Nginx and PHP-FPM:

$ sudo /etc/init.d/nginx restart
$ sudo /etc/init.d/php5-fpm restart

Load the info.php file located here.

Post to Twitter

This entry was posted in PHP. Bookmark the permalink.

7 Responses to Install Nginx with PHP 5.3.3 (PHP-FPM) on Ubuntu 10.10

  1. Pingback: Install Nginx with PHP 5.3.3 (PHP-FPM) on Ubuntu 10.10

  2. max says:

    thank you thank you best of yes is

  3. Nicholas says:

    Thanks so much for this! I’d tried several other walkthroughs, and none of them worked for me. Turns out the part that was missing in the others was the fastcgi_param setting.

  4. Good and simple tutorial! However, let me point out that you could simply use this line, instead of harcoding the absolute path:

    $document_root$fastcgi_script_name

    Cheers ; )

  5. Chad Lung says:

    @Frederic,

    Thanks!

    Chad

  6. Pingback: Submit a JQuery Mobile form via AJAX with PHP | Giant Flying Saucer

  7. fastcgi_index is only used when request URI ends with slash. Which will never be the case in location ~ \.php$

Comments are closed.