1.安装yum -y install libxml2-devel openssl-devel bzip2-devel libmcrypt-devel 解决php包的依赖关系,可能libmcrypt会报错,先执行yum install epel-release,再重新安装一下就可以了。
2.下载PHP安装包并且上传到服务器,解压,(或者可以用wget直接下载到服务器)。
3.在PHP包的位置编译php:
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm --with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--with-mcrypt \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--disable-fileinfo \
--enable-maintainer-zts
4.make && make install
5.复制相关配置文件到相关位置上:
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
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
6.加权限并设置开机启动php
7.开启php服务:
/usr/local/php/sbin/php-fpm或者 /etc/init.d/php-fpm start
8.查看php是否启动成功:
netstat -lnt |grep 9000
9.建一个存放nginx日志的文件与网站根目录:
mkdir -p /tmp/www/feiyin.com
mkdir -p /tmp/www/feiyin.com
原文:https://www.cnblogs.com/zteng/p/10445824.html