Installing Nginx With PHP 5.3 And PHP-FPM On Ubuntu Lucid Lynx (10.04)
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
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:
You are now finished. If you have any questions or concerns, do not hesitate to contact me.