php7.2编译安装记录
目录
1 php7.2新特性
- 增加新的类型object
- 通过名称加载扩展
3.允许重写抽象方法
当一个抽象类继承于另外一个抽象类的时候,继承后的抽象类可以重写被继承的抽象类的抽象方法。 - 使用Argon2算法生成密码散列
Argon2 已经被加入到密码散列(password hashing) API (这些函数以 password_ 开头), 以下是暴露出来的常量 - 新增 PDO 字符串扩展类型
当你准备支持多语言字符集,PDO的字符串类型已经扩展支持国际化的字符集。以下是扩展的常量: - 命名分组命名空间支持尾部逗号
2 安装php7.2
下载php7.2包
wget http://am1.php.net/get/php-7.2.4.tar.xz/from/this/mirror php-7.2.4.tar.xz
$ xz -d php-7.2.4.tar.xz
$ tar -xvf php-7.2.4.tar
查看上个安装版本的配置
$ php -i | grep configure
Configure Command => './configure' '--prefix=/usr/local/fffmo.com/php7' '--with-config-file-path=/usr/local/fffmo.com/php7/etc' '--with-zlib-dir' '--with-freetype-dir' '--enable-mbstring' '--with-libxml-dir=/usr' '--enable-soap' '--enable-calendar' '--with-curl' '--with-mcrypt' '--with-gd' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-zlib' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-pcntl' '--enable-mbregex' '--enable-exif' '--enable-bcmath' '--with-mhash' '--enable-zip' '--with-pcre-regex' '--with-pdo-mysql' '--with-mysqli' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--with-openssl' '--with-fpm-user=www-data' '--with-fpm-group=www-data' '--enable-ftp' '--with-imap' '--with-imap-ssl' '--with-kerberos' '--with-gettext' '--with-xmlrpc' '--with-xsl' '--enable-opcache' '--enable-fpm'
格式一下命令,之前使用反斜线()执行的命令,显示成了单引号, 再将 单引号转换成 反斜线, 具体配置命令如下:
./configure --prefix=/usr/local/fffmo.com/php7.2 \
--with-config-file-path=/usr/local/fffmo.com/php7.2/etc \
--with-zlib-dir \
--with-freetype-dir \
--enable-mbstring \
--with-libxml-dir=/usr \
--enable-soap \
--enable-calendar \
--with-curl \
--with-mcrypt \
--with-gd \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--enable-exif \
--enable-bcmath \
--with-mhash \
--enable-zip \
--with-pcre-regex \
--with-pdo-mysql \
--with-mysqli \
--with-mysql-sock=/var/run/mysqld/mysqld.sock \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--enable-gd-native-ttf \
--with-openssl \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--enable-ftp \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--with-gettext \
--with-xmlrpc \
--with-xsl \
--enable-opcache \
--enable-fpm
稍等一会,等配置执行完毕后,再接着编译和安装命令,执行:
$ make
$ make install
使用全路径查看php版本:
$ /usr/local/fffmo.com/php7.2/bin/php -v
PHP 7.2.4 (cli) (built: Apr 7 2018 16:51:41) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
删除原来的软连接,建立新软连接到/usr/local/bin/目录:
$ rm /usr/local/bin/php*
$ sudo ln -s /usr/local/fffmo.com/php7.2/bin/php* /usr/local/bin/
现在 php -v 就可以看到新版本了:
$ php -v
PHP 7.2.4 (cli) (built: Apr 7 2018 16:51:41) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
复制原来的配置文件到新的目录:
$ cp /usr/local/fffmo.com/php7/etc/php-fpm.conf /usr/local/fffmo.com/php7.2/etc/php-fpm.conf
$ cp /usr/local/fffmo.com/php7/etc/php-fpm.d/www.conf /usr/local/fffmo.com/php7.2/etc/php-fpm.d/www.conf
重启
使用 ps 查看php进程,使用 kill 结束开启中的php进程, 再重启php-fpm:
$ ps -ef |grep php
$ sudo kill -9 2719
$ sudo /usr/local/fffmo.com/php7.2/sbin/php-fpm
参考:
PHP 7.2.x 中废弃的功能
PHP 5.6,7.0,7.1,7.2 和 HHVM 运行效率比较