Source compilation Nginx + php-FPM Part 2

Tags: compilationNginxPHp-FPMsource

Published on: January 6, 2011 by Jithin Vijayan

Source compilation Nginx + php-FPM  Part 2


Now Nginx server support team providing the next part where php is compiled with php-fpm

Before installation we need to install some of the required libraries

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

Download the php version 5.3.3 where the php-fpm is an inbuilt


tar -xzf php-5.3.3.tar.gz

cd php-5.3.3

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

I have customised the options according to my choice here, where as for enabling the fpm “–enable-fpm” only this is required.


make test

make install

The installation is completed

You may copy some of the default configuration from the downloaded package to installation file here I am copying the devolopment php.ini along with the conf

cp php.ini-development /usr/local/php/php.ini

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

or you can download it from the url

chmod 755 /etc/init.d/php-fpm 

Adding php-fpm to auto-run on each login

update-rc.d -f php-fpm defaults

Adding system startup for /etc/init.d/php-fpm …
/etc/rc0.d/K20php-fpm -> ../init.d/php-fpm
/etc/rc1.d/K20php-fpm -> ../init.d/php-fpm
/etc/rc6.d/K20php-fpm -> ../init.d/php-fpm
/etc/rc2.d/S20php-fpm -> ../init.d/php-fpm
/etc/rc3.d/S20php-fpm -> ../init.d/php-fpm
/etc/rc4.d/S20php-fpm -> ../init.d/php-fpm
/etc/rc5.d/S20php-fpm -> ../init.d/php-fpm

/etc/init.d/php-fpm start 

Some of the errors and their fix I found during the installation

Installation during nginx when ./configure was run


checking for PCRE library … not found
checking for PCRE library in /usr/local/ … not found
checking for PCRE library in /usr/include/pcre/ … not found
checking for PCRE library in /usr/pkg/ … not found
checking for PCRE library in /opt/local/ … not found

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using –without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using –with-pcre=<path> option.

sudo aptitude install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev 

Error found when php-fpm was started

/etc/init.d/php-fpm start
Starting php-fpm Nov 24 17:17:05.586113 [ALERT] [pool www] pm.min_spare_servers(0) must be a positive value
Nov 24 17:17:05.586173 [ERROR] failed to post process the configuration

You just need to make sure these values are not commented in /usr/local/php/etc/php-fpm.conf

pm = dynamic
pm.max_children = 50
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 35

Another one that came around was

/etc/init.d/php-fpm start
Starting php-fpm .Nov 24 17:21:48.489194 [ERROR] [pool www] cannot get gid for group ‘nobody’
……………………………. failed

either you can create a group for nobody

groupadd nobody

or can change it in your php-fpm.conf

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user’s group
;       will be used.
user = www-data
group = nobody

Category : cPanel, General, Howtos, Linux, Special Offers, Training, Troubleshooting

Jithin Vijayan

Jithin Vijayan

One of the most inquisitive person you may come across in your life :-). His enthusiasm to unearth the existing technologies and excellent comprehension skills makes him one of the most dependable admin during critical situations. Jithin loves trekking and photography.

You may also read:


Add new commentSIGN IN

Let's Connect


Your Cart

Cart is empty.

Send this to a friend