5安装依赖,安装 epel 是为了安装 libmcrypt-devel mhash-devel
rpm -ivh http://mirrors.sohu.com/fedora-epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
安装库
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel pcre-devel zlib-devel gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel bison automake zlib* libxml* ncurses-devel libtool-ltdl-devel* mysql-devel libmcrypt-devel mhash-devel
编译
wget http://am1.php.net/get/php-7.1.15.tar.gz/from/this/mirror -O php-7.1.15.tar.gz
tar zxvf php-7.1.15.tar.gz && cd php-7.1.15
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-mysqli --with-mcrypt --with-zlib --enable-mbstring --with-curl --with-mhash --enable-sockets --with-openssl --with-gd --with-freetype-dir --with-jpeg-dir --with-pdo-mysql
make && make install
cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
vim /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
启动 php-fpm
/usr/local/php/sbin/php-fpm -g /usr/local/php/var/run/php-fpm.pid &
设置开机启动
echo "/usr/local/php/sbin/php-fpm -g /usr/local/php/var/run/php-fpm.pid &" >> /etc/rc.d/rc.local
配置, 在nginx 配置的 server 里面加入
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
查看
echo "" > /web/info.php
php-fpm 关闭:
kill -INT `cat /usr/local/php/var/run/php-fpm.pid`
php-fpm 重启:
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
查看php-fpm进程数:
ps aux | grep -c php-fpm
安装 redis php扩展
cd ~ && wget http://pecl.php.net/get/redis-4.0.0.tgz
tar zxvf redis-4.0.0.tgz && cd redis-4.0.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
在/usr/local/php/etc/php.ini 最后加上
vim /usr/local/php/etc/php.ini
extension=redis.so