1.获取php源码包
2.解压
tar jxf php-5.6.35.tar.bz2
3.安装依赖性软件
yum install -y net-snmp-devel \
libmcrypt-* \
gmp-devel-4.3.1-7.el6_2.2.x86_64 \
freetype-devel \
2:libpng-devel-1.2.49-1.el6_2.x86_64 \
libjpeg-turbo-devel-1.2.1-1.el6.x86_64 \
libcurl-devel \
openssl-devel \
libxml2-devel
4.进入目录安装php
cd php-5.6.35
./configure --prefix=/usr/local/lnmp/php \
--with-config-file-path=/usr/local/lnmp/php/etc \
--with-openssl \
--with-snmp \
--with-gd \
--with-zlib \
--with-curl \
--with-libxml-dir \
--with-png-dir \
--with-jpeg-dir \
--with-freetype-dir \
--with-gmp \
--with-gettext \
--with-pear \
--enable-mysqlnd \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-inline-optimization \
--enable-soap \
--enable-ftp \
--enable-sockets \
--enable-mbstring \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-mcrypt \
--with-mhash
make && make install
编译安装php
5.配置php
cd /usr/local/lnmp/php/etc/
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
删除pid前面的分号。
cd php-5.6.35
cp php.ini-production /usr/local/lnmp/php/etc/php.ini
vim /usr/local/lnmp/php/etc/php.ini
进入php安装目录,复制文件,修改时区
cd php-5.6.35
cd sapi/fpm/
cp init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
复制启动脚本到/etc/inin.d/下,并给执行权限。
useradd nginx
添加用户之后就可以正常启动php了。