CentOS Nginx + PHP-FPM (Part 2)

PHP-FPMSo Nginx is now installed if you followed part 1, before we configure that though it’s probably going to be easier to install php-fpm and do all the config in one go.
This isn’t as simple as Nginx as we are installing and patching from source, but if you have all the dependences installed it should go smooth if not don’t panic.
So first step is to check we have the dependences , if not we will just get them installed for us.

yum install libjpeg-devel libpng-devel libmcrypt libmcrypt-devel pcre pcre-devel libxml2-devel curl-devel mysql-devel

So we need to download the required version of PHP, and also the patch file to add FPM onto PHP.
At the time of writing this 5.3 isn’t 100% stable, so I am going for 5.2.17, however I will upgrade soon.
Go here (http://php.net/downloads.php) to get the PHP version you want, don’t just use the one below, as it’s probably now out of date

cd /
wget http://uk.php.net/get/php-5.2.17.tar.bz2/from/this/mirror

The patch is different for each version you download, so look here (http://php-fpm.org/downloads/) to get the right one:

wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz

Now you need to unzip the main PHP download, then unzip the patch file and merge both of these together, remember to change the below commands to match which ever version you downloaded.

tar xvf php-5.2.17.tar.bz2
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
cd php-5.2.17

So that’s the patching done, and we are now in the PHP directory, time to get it configured for your system.

32Bit Systems:

./configure --enable-fastcgi --enable-fpm --with-mcrypt --enable-mbstring --enable-mysql --with-mysql=/usr --with-mysql-sock=/tmp/mysql.sock --with-curl --with-sockets --with-gd --with-zlib --with-iconv --with-dom --with-jpeg-dir=/usr/li

64Bit Systems (also has –with-libdir=lib64):

./configure --enable-fastcgi --enable-fpm --with-mcrypt --enable-mbstring --enable-mysql --with-mysql=/usr --with-mysql-sock=/tmp/mysql.sock --with-libdir=lib64 --with-curl --with-sockets --with-gd --with-zlib --with-iconv --with-dom --with-jpeg-dir=/usr/li

If you get any error’s your probably missing a dependency on the server, normally just a good idea to Google the error message. Also make sure you used the right configure command depending on your architecture. These commands might take a while, they did on my slow VM.

make test
make install
nano /usr/local/etc/php-fpm.conf

Make sure the two user/group lines are not commented out, they normally are.

Next as php-fpm doesn’t support chkconfig, we will just add a referance in rc.local, so it will start on bootup.
If for some reason you don’t want it to start on boot, skip this step.

nano /etc/rc.local

Add this line to the end of the file.

/etc/init.d/php-fpm start

So that’s it for php-fpm, I will go into the configuration of it and Nginx in part 3.

Technology enthusiastic with many ongoing online projects one of which is this personal blog PingBin. While also working full time within a data center designing and maintaining the network infrastructure.

Leave a reply:

Your email address will not be published.