#下载地址
http://www.php.net/downloads.php
#如果编译不通过,可以安装以下工具(选择性安装)
sudo yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel \
libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \
glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel\
e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel \
openldap openldap-devel nss_ldap openldap-clients openldap-servers \
php-mysqlnd libmcrypt-devel libtidy libtidy-devel recode recode-devel libxpm-devel
#编译参数
./configure \
--prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--enable-mbstring \
--enable-zip \
--enable-bcmath \
--enable-pcntl \
--enable-ftp \
--enable-exif \
--enable-calendar \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-opcache \
--enable-fpm \
--enable-session \
--enable-sockets \
--enable-mbregex \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-wddx \
--with-curl \
--with-mcrypt \
--with-iconv \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-freetype-dir=/usr \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-openssl \
--with-pdo-mysql=mysqlnd \
--with-gettext=/usr \
--with-zlib=/usr \
--with-bz2=/usr \
--with-recode=/usr \
--with-xmlrpc \
--with-mysqli=mysqlnd
#配置文件
sudo cp php.ini-production /usr/local/php7/etc/php.ini
sudo cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
sudo cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
sudo cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
#增加启动脚本的权限
sudo chmod +x /etc/init.d/php7-fpm
#做一些软链
ln -s /usr/local/php7/bin/php /usr/bin/php7
ln -s /usr/local/php7/bin/php-config /usr/bin/php7-config
ln -s /usr/local/php7/bin/phpize /usr/bin/php7ize
ln -s /usr/local/php7/sbin/php-fpm /usr/sbin/php7-fpm
#nginx中找到fastcgi_pass的位置
fastcgi_pass unix:/tmp/php-cgi.sock;
#复制php5的php-fpm.conf
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 40
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log
catch_workers_output = yes