ubuntu16.04环境LNMP实现PHP5.6和PHP7.2

最近因为公司突然间说要升级php7,所以做个记录

PPA 方式安装 php7.2 :

sudo apt-get install software-properties-common

添加 php7 的 PPA

sudo add-apt-repository ppa:ondrej/php 

更新安装包

sudo apt-get update 

运行这行命令的时候,报错了,错误信息如下

Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then appstreamcli refresh > /dev/null; fi'

解决方法(三局命令)

sudo pkill -KILL appstreamcli

wget -P /tmp https://launchpad.net/ubuntu/+archive/primary/+files/appstream_0.9.4-1ubuntu1_amd64.deb https://launchpad.net/ubuntu/+archive/primary/+files/libappstream3_0.9.4-1ubuntu1_amd64.deb

sudo dpkg -i /tmp/appstream_0.9.4-1ubuntu1_amd64.deb /tmp/libappstream3_0.9.4-1ubuntu1_amd64.deb

检验是否安装成功,运行命令如若成功就能开始安装php7.2

apt-cache search php7.2

php7.2安装

sudo apt-get -y install php7.2

apt-get install php7.2-dev

安装PHP7.2的各个模块

sudo apt-get -y install php7.2-mysql

sudo apt-get install php7.2-fpm

apt-get install php7.2-curl php7.2-xml php7.2-json php7.2-gd php7.2-mbstring

执行 whereis php | grep php7.2 找到对应的命令(/usr/bin/php7.2),执行/usr/bin/php7.2 -v 查看信息

附注参考资料:https://www.linuxidc.com/Linux/2018-08/153463.htm

原文地址:https://www.cnblogs.com/zhp-king/p/11047880.html