Ubuntu 14.04 升级PHP 和 Apache

栏目: PHP · 发布时间: 4年前

内容简介:Ubuntu上官方的源,比如 Ubuntu14.04 默认源中的是 PHP5.6.x、Ubuntu16.04 默认源中的是 PHP7.0.x,那么如果想在 Ubuntu16.04 上安装 PHP7.1,PHP7.2,应该怎么办呢?答案是通过第三方的源来安装,ppa:ondrej/php 是一个比较知名的PHP源(目前维护php5.6,php7.0,php7.1,php7.2)。下面就用这个源来安装自己想要的PHP版本。首先添加一个 PHP 7.0 更新源:

Ubuntu上官方的源,比如 Ubuntu14.04 默认源中的是 PHP 5.6.x、Ubuntu16.04 默认源中的是 PHP7.0.x,那么如果想在 Ubuntu16.04 上安装 PHP7.1,PHP7.2,应该怎么办呢?

答案是通过第三方的源来安装,ppa:ondrej/php 是一个比较知名的PHP源(目前维护php5.6,php7.0,php7.1,php7.2)。下面就用这个源来安装自己想要的PHP版本。

首先添加一个 PHP 7.0 更新源:

sudo add-apt-repository ppa:ondrej/php

If add-apt-repository is not available in your VPS, install it.  sudo apt-get install software-properties-common

然后运行更新命令:

sudo apt-get update

接下来使用通过如下命令安装 PHP 7.0:

sudo apt-get install php7.0

sudo apt-get install php7.1 # for PHP 7.1

sudo apt-get install php7.0 # for PHP 7.0

sudo apt-get install php5.6 # for PHP 5.6

然后安装两个必备扩展包:

sudo apt-get install php7.0-mysql

sudo apt-get install php7.0-fpm

再根据项目需要选择安装相应的可选扩展包:

sudo apt-get install php7.0-curl php7.0-dom php7.0-gd php7.0-mbstring php7.0-memcached php7.0-zip

sudo apt-get install php7.2-curl php7.2-dev php7.2-gd php7.2-imap php7.2-intl php7.2-mbstring php7.2-mysql php7.2-xml php7.2-zip

至此,升级工作结束,接下来我们需要启动新的 FPM 服务:

sudo service php7.0-fpm restart

切换PHP版本

sudo update-alternatives –config php

设置Apache与正确的PHP版本一起运行

sudo a2dismod php7.1        # unload the current version

sudo a2enmod  php5.6        # load the version you need

sudo service apache2 restart # restart webserver to apply

同样,使用如下命令更新Apache2:

add-apt-repository ppa:ondrej/apache2

apt-get install apache2


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Don't Make Me Think

Don't Make Me Think

Steve Krug / New Riders Press / 18 August, 2005 / $35.00

Five years and more than 100,000 copies after it was first published, it's hard to imagine anyone working in Web design who hasn't read Steve Krug's "instant classic" on Web usability, but people are ......一起来看看 《Don't Make Me Think》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具