Linux版本:CentOS 6.7
内核版本:2.6.32-573.el6.x86_64
PHP版本:5.4.37
创建用户php-fpm:
# useradd -s /sbin/nologin php-fpm
配置编译参数:
# cd php-5.4.37
# ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--with-mysql=/usr/local/mysql \
--with-mysql-sock=/tmp/mysql.sock \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--enable-zend-multibyte \
--disable-ipv6 \
--with-pear \
--with-curl \
--with-openssl
如果配置过程中出现了一些错误,一般都是因为缺少了一些库,最好在配置之前下载一些库文件:
# yum install -y gcc libxml2 libxml2-devel openssl openssl-devel libcurl libcurl-devel libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel
像libmcrypt文件在CentOS 6的yum源里是不存在的,所以安装这个库文件之前要安装一个第三方的源:
# rpm -ivh ‘http://www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm‘
库文件安装好后,再进行配置,完成后echo $?, 如果输出的是0,那么就可以进行编译了,否则就看着办吧
编译,安装:
# make && make install
每一步完成后都要 echo $? 看一看有没有不等于0的
拷贝php全局配置文件php.ini:
# cp php.ini-production /usr/local/php/etc/php.ini
修改php-fpm配置文件php-fpm.conf :
# vim /usr/local/php/etc/php-fpm.conf
把如下内容写入该文件: 其中包含www.test.com这个测试站的池子www, 以及供nginx来读取的sock文件
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[test]
listen = /tmp/test.sock
user = php-fpm
group = php-fpm
listen.owner = nobody
listen.group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
配置完成后检验配置是否正确:
# /usr/local/php/sbin/php-fpm -t
拷贝php-fpm的启动脚本文件:
# cp /usr/local/src/php-5.4.37/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod 755 /etc/init.d/php-fpm
启动php-fpm:
# service php-fpm start
查看php-fpm的进程是否正常启动:
# ps aux |grep php-fpm