How to Install PHP-FPM on CentOS 6.2

 PHP-FPM (FastCGI Process Manager) is a PHP FastCGI implementation and is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. PHP-FPM is a set of patches for PHP to work with the FastCGI process manager, turning PHP-FPM into a service rather than loading all of its libraries everytime a PHP request it’s made. In this post, i will show on how to install PHP-FPM on linux CentOS 6.2 server. Assume that you have configured EPEL and remi repositories on you linux CentOS 6.2 server

一、How to Install and Configure EPEL Repository on CentOS 6.2

 

In this post, i will show you on how to install and configure the Extra Packages for Enterprise Linux (EPEL) repository on CentOS 6.2. EPEL repository is another extra repository that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL) and CentOS server. To install the repository, you can follow this steps :

1. First we import the GPG keys for EPEL software packages:

 

[root@centos62 ~]# wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
[root@centos62 ~]# wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
--2012-03-07 22:08:39--  http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
Resolving ftp.riken.jp... 134.160.38.1
Connecting to ftp.riken.jp|134.160.38.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1649 (1.6K) [text/plain]
Saving to: âRPM-GPG-KEY-EPEL-6â

100%[==========================================================>] 1,649       --.-K/s   in 0.002s

2012-03-07 22:08:40 (929 KB/s) - âRPM-GPG-KEY-EPEL-6â

2. Then we enable the EPEL repositories using the following command :

[root@centos62 ~]# rpm --import RPM-GPG-KEY-EPEL-6

3. Download EPEL repository for 32-bit CentOS :

[root@centos62 ~]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
[root@centos62 ~]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
--2012-03-07 22:06:10--  http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
Resolving dl.fedoraproject.org... 209.132.181.27, 209.132.181.23, 209.132.181.24, ...
Connecting to dl.fedoraproject.org|209.132.181.27|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14064 (14K) [application/x-rpm]
Saving to: âepel-release-6-5.noarch.rpmâ

100%[==========================================================>] 14,064      36.7K/s   in 0.4s

2012-03-07 22:06:14 (36.7 KB/s) - âepel-release-6-5.noarch.rpmâ

4. Install EPEL repository on 32-bit CentOS :

[root@centos62 ~]# rpm -ivh epel-release-6-5.noarch.rpm
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

5. Edit the the EPEL repository file and Set priority for the EPEL repository as below :

[root@centos62 ~]# vi /etc/yum.repos.d/epel.repo

6. Add priority=3 to the [epel] section, under enabled=1 :

 

[epel] name=Extra Packages for Enterprise Linux 6 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority enabled=1 priority=3 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 [epel-debuginfo] name=Extra Packages for Enterprise Linux 6 - $basearch - Debug #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 6 - $basearch - Source #baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=1

二、How to Install Remi yum Repository on CentOS 6.2

There are several 3rd party repositories for CentOS 6 server. One of the popular one is remi repository. The Remi repository is a repository containing updated PHP and MySQL packages and is maintained by Remi. In this post, i will show you on how to install remi repository on linux CentOS 6.2 server

Import the RPM-GPG-KEY key and install remi rpm package :

[root@centos62 ~]# rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
[root@centos62 ~]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Retrieving http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Preparing...                ########################################### [100%]
   1:remi-release           ########################################### [100%]

To enable this repo, please change “enabled” value to 1 :

[remi]
name=Les RPM de remi pour Enterprise Linux $releasever - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/$releasever/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
failovermethod=priority

[remi-test]
name=Les RPM de remi en test pour Enterprise Linux $releasever - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/$releasever/test/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/test/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

三、

1. How to install PHP and other php extensions :

[root@centos62 ~]# yum --enablerepo=remi install php php-fpm php-common php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

Output :

  Installing : libmemcached-1.0.4-1.el6.remi.i686                                              8/23
  Installing : php-pecl-memcached-2.0.1-2.el6.remi.i686                                        9/23
  Installing : php-mysql-5.4.0-1.el6.remi.i686                                                10/23
  Installing : php-gd-5.4.0-1.el6.remi.i686                                                   11/23
  Installing : php-pecl-mongo-1.2.10-2.el6.remi.i686                                          12/23
  Installing : php-pecl-apc-3.1.10-2.el6.remi.i686                                            13/23
  Installing : php-pecl-memcache-3.0.6-3.el6.remi.i686                                        14/23
  Installing : php-pecl-sqlite-2.0.0-0.1.svn313074.el6.remi.i686                              15/23
  Installing : php-5.4.0-1.el6.remi.i686                                                      16/23
  Installing : php-pgsql-5.4.0-1.el6.remi.i686                                                17/23
  Installing : php-mcrypt-5.4.0-1.el6.remi.i686                                               18/23
  Installing : php-xml-5.4.0-1.el6.remi.i686                                                  19/23
  Installing : php-fpm-5.4.0-1.el6.remi.i686                                                  20/23
  Installing : php-mbstring-5.4.0-1.el6.remi.i686                                             21/23
  Installing : compat-mysql51-5.1.54-1.el6.remi.i686                                          22/23
  Cleanup    : mysql-libs-5.1.61-1.el6_2.1.i686                                               23/23

Installed:
  php.i686 0:5.4.0-1.el6.remi                           php-cli.i686 0:5.4.0-1.el6.remi
  php-common.i686 0:5.4.0-1.el6.remi                    php-fpm.i686 0:5.4.0-1.el6.remi
  php-gd.i686 0:5.4.0-1.el6.remi                        php-mbstring.i686 0:5.4.0-1.el6.remi
  php-mcrypt.i686 0:5.4.0-1.el6.remi                    php-mysql.i686 0:5.4.0-1.el6.remi
  php-pdo.i686 0:5.4.0-1.el6.remi                       php-pear.noarch 1:1.9.4-7.el6.remi
  php-pecl-apc.i686 0:3.1.10-2.el6.remi                 php-pecl-memcache.i686 0:3.0.6-3.el6.remi
  php-pecl-memcached.i686 0:2.0.1-2.el6.remi            php-pecl-mongo.i686 0:1.2.10-2.el6.remi
  php-pecl-sqlite.i686 0:2.0.0-0.1.svn313074.el6.remi   php-pgsql.i686 0:5.4.0-1.el6.remi
  php-xml.i686 0:5.4.0-1.el6.remi

Dependency Installed:
  compat-mysql51.i686 0:5.1.54-1.el6.remi                   libmemcached.i686 0:1.0.4-1.el6.remi
  php-pecl-igbinary.i686 0:1.1.2-0.1.git3b8ab7e.el6.remi    t1lib.i686 0:5.1.2-6.el6_2.1

Dependency Updated:
  mysql-libs.i686 0:5.5.22-1.el6.remi

Complete!

2. How to check PHP Version :

[root@centos62 ~]# php -v
PHP 5.4.0 (cli) (built: Mar  2 2012 17:49:53)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

3. Proceed to configure PHP-FPM to meet your requirement :

[root@centos62 ~]# vi /etc/php-fpm.d/www.conf

4. Start PHP-FPM :

[root@centos62 ~]# service php-fpm start
Starting php-fpm:                                          [  OK  ]

 

 

 

 

 

 

 

你可能感兴趣的:(centos,6.2,php-fpm)