【源码方式安装php-7.2.5及php-fpm】
卸载旧版本php(centos7默认的是php5.4)
yum list installed | grep php
然后将结果中的一个人yum remove XX 掉
或者yum remove php*批量删除掉
yum -y install bzip2
yum -y install zip
yum -y install unzip
yum -y install gcc
yum -y install libxml2
yum -y install libxml2-devel
yum -y install m4
yum -y install autoconf
yum -y install openssl openssl-devel
yum -y install zip unzip
yum -y install curl
yum -y install wget
yum -y install libpng-devel
wget http://cn.php.net/distributions/php-7.2.5.tar.gz
tar -zxvf php-7.2.5.tar.gz
cd php-7.2.5.tar.gz
以下带的这几个参数非常重要,装了好多次才试出来的,终于成功了;
加了这几个参数后,php.ini中的扩展中就不需要开启了,貌似是安装到php内部去了,其它没有在这里指定要开启的扩展就需要自行编译安装并在php.ini中开启
不加这几个参数,后面安装数据库后连接不上
--enable-maintainer-zts这一项在后期项目用到mongodb时折腾了好久才发现要开启这个,否则编译安装后mongodb.so在php-fpm启动时一直报错;
./configure --enable-fpm --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-maintainer-zts
成功后会看到:
Thank you for using PHP.
config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config