Install mysql, mysql-devel, & mysql-libs with yum. Then add rpmforge repo because we’re going to install libmcrypt-devel that doesn’t available on standard Centos Repo.
rpm -Uvh http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
or you can follow direction here
Dont forget to disable RPMForge because all we need from there is just libmcrypt.
nano /etc/yum.repos.d/rpmforge.repo
Edit line contain “enabled=1″ and change it to 0 :
enabled = 0
Install libmcrypt-devel & other dependencies:
yum --enablerepo=rpmforge install libmcrypt-devel
yum install libc-client-devel
Download and install PHP :
cd /usr/local/src
wget http://id.php.net/distributions/php-5.3.8.tar.gz
cd /usr/local/
tar -zxvf src/php-5.3.8.tar.gz
cd php-5.3.8/
Now we’re going to make configure file :
nano konfig
Copy and paste :
./configure \
--enable-fpm \
--with-mcrypt \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--with-mysql \
--with-libdir=lib64 \
--enable-ftp \
--enable-gd-native-ttf \
--enable-libxml \
--enable-magic-quotes \
--enable-mbstring \
--enable-soap \
--enable-sockets \
--enable-zip \
--prefix=/usr \
--with-curl=/usr \
--with-curlwrappers \
--with-freetype-dir=/usr \
--with-gd \
--with-gettext \
--with-imap \
--with-imap-ssl=/usr \
--with-kerberos \
--with-jpeg-dir=/usr \
--with-libexpat-dir=/usr \
--with-libxml-dir=/usr \
--with-mysqli \
--with-openssl=/usr \
--with-openssl-dir=/usr \
--with-pic \
--with-png-dir=/usr \
--with-pspell \
--with-xmlrpc \
--with-xpm-dir=/usr \
--with-xsl \
--with-zlib \
--with-zlib-dir=/usr \
--enable-inline-optimization \
--with-bz2 \
--with-pdo-mysql=shared \
--with-pdo-sqlite=shared \
--with-sqlite=shared \
--enable-wddx \
--with-mhash \
--enable-sysvsem \
--enable-sysvshm \
--enable-mbregex
Chmod file konfig to be executable :
chmod +x konfig
./konfig
make
make install
Now copy PHP-FPM init.d script to /etc/init.d :
cp /usr/local/php-5.3.8/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
Let’s edit it :
nano /etc/init.d/php-fpm
Change these lines :
php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=/etc/php/php-fpm.conf
php_fpm_PID=/var/run/php-fpm.pid
We’ll make a php configuration folder under /etc and logging under /var/log/nginx :
mkdir /etc/php
mkdir /etc/php/fpm.d
mkdir /var/log/nginx
cp php.ini-production /usr/lib/php.ini
ln -s /usr/lib/php.ini /etc/php/
nano /etc/php/php-fpm.conf
Copy paste and save :
[global]
pid = /var/run/php-fpm.pid
error_log = /var/log/php-fpm.log
log_level = notice
emergency_restart_threshold = 50
emergency_restart_interval = 600
process_control_timeout = 600
daemonize = yes
;rlimit_files = 1024
;rlimit_core = 0
include=/etc/php/fpm.d/*.conf
Make PHP FPM pool configuration sample :
nano /etc/php/fpm.d/sample-conf.1
Copy paste :
[www]
listen = 127.0.0.1:9000
;listen.backlog = -1
;listen.allowed_clients = 127.0.0.1
listen.owner = username
listen.group = username
;listen.mode = 0666
; 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 = username
group = username
pm = dynamic
; Default value
;pm.max_children = 50
;pm.start_servers = 20
;pm.min_spare_servers = 5
;pm.max_spare_servers = 35
;pm.max_requests = 500
;pm.status_path = /status
; Minimized value
pm.max_children = 11
pm.start_servers = 8
pm.min_spare_servers = 2
pm.max_spare_servers = 10
pm.max_requests = 100
;ping.path = /ping
;ping.response = pong
;access.log = /var/log/nginx/$pool.access.log
;access.format = %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%
request_terminate_timeout = 30
;request_slowlog_timeout = 31
;slowlog = /var/log/nginx/$pool.log.slow
;rlimit_files = 1024
;rlimit_core = 0
;chroot =
;chdir = /var/www
catch_workers_output = yes
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/nginx/$pool.error.log
php_admin_flag[log_errors] = off
php_admin_value[memory_limit] = 128M
Now you’re ready. I assume this installation is for multiple vhost, so if you need to add vhost just make a copy of /etc/php/fpm.d/sample-conf.1 (copy to vhostname.conf) and /etc/nginx/sites-available/01-sample.conf then add link to /etc/nginx/sites-enabled/




Pingback: Install NGINX & PHP 5.3 with FPM on Centos 6 (1) | Web Development | Networking | System Administration