ubuntu更换源并安装PHP

参考地址:https://blog.csdn.net/github_38336924/article/details/83748533

环境:ubuntu 16.04 Server
Ubuntu16.04 默认源中的是 PHP7.0.x ,通过更换源以后增加其他PHP版本(5.6,7.0,7.1,7.2,7.3,7.4,8.0)

更换ppa源

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

查看PHP列表

sudo apt list | grep php

安装php7.2

sudo apt-get -y install php7.2

更换阿里云的源

更换之前先查看/etc/apt/sources.list中的URL是archive.ubuntu还是cn.archive.ubuntuus.archive.ubuntu

然后在执行下面的命令


sudo sed -i 's/cn.archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 

sudo sed -i 's/us.archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list

sudo sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list

执行之后,更新源

sudo apt-get update 

版权声明:本文为qq_39965424原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。