Installing Nginx With PHP 5.3 And PHP-FPM On Ubuntu Lucid Lynx (10.04)

Want to support HowtoForge? Become a subscriber!
 
Submitted by kjette (Contact Author) (Forums) on Fri, 2010-06-11 13:41. :: Ubuntu | Web Server | nginx | PHP

Installing Nginx With PHP 5.3 And PHP-FPM On Ubuntu Lucid Lynx (10.04)

Follow me on Twitter

http://kjette.se/blog/2010/06/nginx-php-fpm-ubuntu-lucid-lynx/

In this post I will explain how to install Nginx with PHP 5.3.3 and PHP-FPM on Ubuntu Lucid Lynx (10.04-amd64). The Lucid release is a Long-Term Support (LTS), meaning that it will be supported for three years on the desktop and for five years with the server version.

 UPDATE 26 September 2010: Updated for the latest PHP 5.3 version (5.3.3).

Step 0 - Preliminary Notes

In order to complete this tutorial you should have a a base system of Ubuntu 10.04.

 

Step 1 - Install Nginx

apt-get install nginx

 

Step 2 - Install all required dependencies for this installation

apt-get install autoconf2.13 libssl-dev libcurl4-gnutls-dev libjpeg62-dev libpng12-dev libmcrypt-dev libmysql++-dev libfreetype6-dev libt1-dev libc-client-dev libbz2-dev mysql-client libevent-dev libxml2-dev

 

Step 3 - Download PHP

cd /usr/local/src

wget http://se.php.net/get/php-5.3.3.tar.gz/from/this/mirror

tar xzf php-5.3.3.tar.gz

Step 4 - Configure PHP

Now to configure the commands we should use with PHP, you can add more stuff if you want to. If you are missing something, you can always ask me and I can help you with that also:

./configure --enable-fpm --enable-soap --with-libevent-dir --with-mcrypt --enable-mbstring --with-openssl --with-mysql --with-mysql-sock --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --with-sqlite=shared --with-pdo-mysql --with-libxml-dir=/usr/lib --with-mysqli=/usr/bin/mysql_config --with-curl --enable-zip --with-bz2 --with-imap=shared --with-imap-ssl --enable-sockets --with-zlib --enable-exif --enable-ftp --with-iconv --with-gettext --enable-gd-native-ttf --with-t1lib=/usr --with-freetype-dir=/usr --with-kerberos --prefix=/usr/local/php --with-fpm-user=www-data --with-fpm-group=www-data

If everything goes well here (which it should), you can run the following command:

make && make install

 

Step 5 - Configuration

Download the vhost configuration (basic, edit for your own needs such as path to your home directory etc):

wget -O /etc/nginx/sites-available/default http://kjette.se/blog/wp-content/downloads/default

Download the php.ini and place it in the correct directory (/usr/local/php/lib) or just run this command:

wget -O /usr/local/php/lib/php.ini http://kjette.se/blog/wp-content/downloads/php.ini

Download php-fpm.conf which is modified to fit kind of every server configuration, but it’s not necessary to change anything:

wget -O /usr/local/php/etc/php-fpm.conf http://kjette.se/blog/wp-content/downloads/php-fpm.conf

If you have problems with php-fpm behaving weird like it takes time to reload, I solved it a while ago by removing one line, but if you want to can download the edited php-fpm init script from here:

wget -O /etc/init.d/php-fpm http://kjette.se/blog/wp-content/downloads/php-fpm

Now you need to reload Nginx and PHP-FPM for all the above stuff to work:

/etc/init.d/nginx reload

/etc/init.d/php-fpm reload

You are now finished. If you have any questions or concerns, do not hesitate to contact me.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by WannaKnow (not registered) on Tue, 2011-05-10 22:37.

Hello kjette,

 Can you please reupload the files (php.ini,default,php-fpm.conf)

 Thanks,

 WannaKnow

Submitted by Anonymous (not registered) on Mon, 2010-11-29 14:26.

Would the original author please cut and paste the contents of the offsite files into this article.

vBulletin does not even attribute these articles to the author any longer. (0 total posts)

I'm thankful for the tutorial but we are forced to recreate the missing content from scratch.

Submitted by fauzievolute (not registered) on Sun, 2010-11-21 07:50.

the blog http://kjette.se/blog/ is taking too long respond, cannot access from my country.

any alternative? whre can i get the configuration?

Submitted by Xanza (not registered) on Thu, 2010-09-23 04:21.
I've been working for almost 4 hours to get nginx to work with Ubuntu 10.04 below Apache2, and you really helped me! Thanks so much. :)
Submitted by Brian Mercer (not registered) on Mon, 2010-07-12 01:57.

Another option for using php-fpm with Lucid 10.04:

http://launchpad.net/~brianmercer/+archive/php

The patches and compile options are the same ones used by the official Ubuntu Lucid php packages.

Submitted by kjette (registered user) on Sun, 2010-09-26 16:02.
Yeah, updated the guide for php 5.3.3 so no patching is necessary.
Submitted by Dmitri Minaev (not registered) on Tue, 2010-06-15 11:21.

Newer FPM does not require to patch PHP sources. You download it to the PHP source tree, untar and then run PHP compilation as usual. I described the installation process here:

Errors when installing PHP 5.3 with FPM on Ubuntu