install php-fpm from source on centos

From WebHostingNeeds.com
Revision as of 06:44, 10 March 2016 by Admin (talk | contribs) (Install PHP 5.x Latest)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Requirements

During PHP install, i had to install following dependency with yum. You may need more depending on what modules you have already installed. If configure fail with error, install devel package for that module.

yum install curl-devel \
libmcrypt-devel \
libtidy-devel \
libxml2-devel libjpeg-devel \
libpng-devel zlib-devel freetype-devel \
gd-devel mhash-devel libmcrypt-devel

Install PHP 5.x Latest

Latest PHP version as on 23-Dec-2015

cd /usr/local/src
wget http://in1.php.net/get/php-5.5.30.tar.gz/from/this/mirror -O php-5.5.30.tar.gz
tar xf php-5.5.30.tar.gz

install imap for php, then

cd /usr/local/src/php-5.5.30
make clean && make distclean
ldconfig
./configure --prefix=/usr/local/php-fpm \
--with-config-file-path=/usr/local/php-fpm/etc \
--with-mysql \
--with-mysqli \
--with-pdo-mysql \
--enable-cgi \
--with-zlib \
--with-gettext \
--enable-ftp \
--enable-calendar \
--enable-bcmath \
--enable-sockets \
--with-curl \
--with-gd \
--with-jpeg-dir=/usr/local \
--enable-mbstring \
--with-freetype-dir=/usr/local \
--with-mhash=/usr/local --enable-exif \
--with-mcrypt=/usr \
--with-tidy \
--with-openssl \
--enable-zip \
--with-imap-ssl \
--with-imap \
--with-kerberos \
--enable-fpm \
--with-apxs2=/usr/sbin/apxs
make && make install



php fpm install confirmation

Copy Configuration Files

cp /usr/local/php-fpm/etc/php-fpm.conf.default /usr/local/php-fpm/etc/php-fpm.conf
cp php.ini-development /usr/local/php-fpm/etc/php.ini
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on



Running PHP-FPM

Ngnix Configuration

Use Socket Instead of TCP Port

It is better to use sockets instead of TCP port to run php-fpm.

vi /usr/local/php-fpm/etc/php-fpm.conf

Find

listen = 127.0.0.1:9000

Replace With

listen = /var/run/php-fpm.sock

In your nginx.conf

vi /etc/nginx/nginx.conf

Find

fastcgi_pass   127.0.0.1:9000;

Replace With

fastcgi_pass  unix:/var/run/php-fpm.sock;



php

php fpm

nginx