yum -y install wget openssl* gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel epel-release glibc ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel OpenIPMI-devel java-devel unixODBC-devel net-snmp-devel libevent-devel libmcrypt-devel openldap-clients openldap-servers make gd gd2 gd-devel gd2-devel libxslt libxslt-devel libaio libaio-devel glibc-devel glib2 glib2-devel bzip2 bzip2-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap libssh2.x86_64 libssh2-devel.x86_64 fping
安装依赖库——libmcrypt
# wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz# tar zxvf libmcrypt-2.5.8.tar.gz# cd libmcrypt-2.5.8/# ./configure# make && make install# /sbin/ldconfig# cd libltdl/# ./configure --enable-ltdl-install# make && make install# ln -sf /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la# ln -sf /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so# ln -sf /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4# ln -sf /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8# ldconfig
安装依赖库——mhash
# wget http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz# tar zxvf mhash-0.9.9.9.tar.gz# cd mhash-0.9.9.9/# ./configure# make && make install# ln -sf /usr/local/lib/libmhash.a /usr/lib/libmhash.a# ln -sf /usr/local/lib/libmhash.la /usr/lib/libmhash.la# ln -sf /usr/local/lib/libmhash.so /usr/lib/libmhash.so# ln -sf /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2# ln -sf /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1# ldconfig
安装依赖库——mcrypt
# wget http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz# tar zxvf mcrypt-2.6.8.tar.gz# cd mcrypt-2.6.8/# ./configure# make && make install
安装PHP
# cp -frp /usr/lib64/libldap* /usr/lib/# cp -frp /usr/lib64/liblber* /usr/lib/# tar -xvf php-7.2.1.tar.gz# cd php-7.2.1./configure --prefix=/usr/local/php \--with-config-file-path=/usr/local/php/etc \--with-mysqli \--with-pdo-mysql \--with-gd \--with-png-dir \--with-jpeg-dir \--with-freetype-dir \--with-libxml-dir \--with-mhash \--with-iconv-dir \--with-mcrypt \--with-openssl \--with-zlib \--with-xmlrpc \--with-curl \--with-gettext \--with-ldap=shared \--with-ldap \--with-ldap-sasl \--enable-xml \--enable-fpm \--enable-gd-native-ttf \--enable-sockets \--enable-ftp \--enable-mbstring \--enable-xml \--enable-zip \--enable-soap \--enable-bcmath \--enable-shmop \--enable-mbregex \--enable-pcntl \--enable-sysvsem \--enable-inline-optimization \--disable-rpath \--without-pear # make && make install
修改配置文件
# cp php.ini-development /usr/local/php/etc/php.ini# cp ./sapi/fpm/php-fpm.conf /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# cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm# vim /usr/local/php/etc/php.inidate.timezone = Asia/Shanghaimax_execution_time = 300post_max_size = 32Mmax_input_time=300memory_limit = 128Mmbstring.func_overload = 0# vim /usr/local/php/etc/php-fpm.conf ggdG #删除所有内容[global]pid = /usr/local/php/var/run/php-fpm.piderror_log = /usr/local/php/var/log/php-fpm.loglog_level = notice[www]user = wwwgroup = wwwlisten = 127.0.0.1:9000 #这里要注意,监听php-fpm有2种,ip或者/tmp/php-cgi.sock,这里选择了ip下面的nginx配置里面要一样。#listen = /tmp/php-cgi.sock #如果启用此项,则需要开启下面的2项或第三项,不然nginx无权限读取socket文件#listen.owner = www#listen.group = www#listen.mode = 0666pm = staticpm.max_children = 60pm.start_servers = 2pm.min_spare_servers = 1pm.max_spare_servers = 3pm.max_requests = 8192slowlog = /usr/local/php/var/log/$pool.logrequest_slowlog_timeout=5srequest_terminate_timeout=10s rlimit_files=65535
设置PHP的环境变量
# vim /etc/profileexport PHP_HOME=/usr/local/phpexport PATH=$PATH:$PHP_HOME/binsource /etc/profile
设置开机启自启动
# cd /etc/init.d/# chmod 744 php-fpm# chkconfig --add php-fpm# chkconfig php-fpm on
创建www组和用户
groupadd wwwuseradd -s /sbin/nologin -g www -M www
启动php-fpm
systemctl restart php-fpm或 /etc/init.d/php-fpm start