You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在AWS EC2 Ubuntu(含14.04)执行apt-get update是否会升级PHP从7.1到7.2?

Does apt-get update Upgrade PHP from 7.1 to 7.2 on AWS EC2 Ubuntu Instances (Including Ubuntu 14.04)?

Great question! Let's break this down step by step to clear up any confusion:

First, a critical distinction: apt-get update vs. apt-get upgrade

Let's start with the basics to avoid mix-ups:

  • apt-get update only refreshes your local package index from the configured repositories. It doesn't install or upgrade any software packages at all—think of it as just telling your system "here's the latest list of available packages and their versions".
  • The commands that actually perform upgrades are apt-get upgrade (upgrades existing packages to their latest available versions in the repo) or apt-get dist-upgrade (handles dependency changes for major version jumps).

So to answer your core question directly: running just apt-get update will never upgrade your PHP version—you'd need to follow it with an upgrade command for that to even be possible.

Now, let's dive into Ubuntu version specifics

Ubuntu 14.04 Trusty Tahr

Ubuntu 14.04 reached its end-of-life (EOL) in April 2019, so official repositories no longer receive any updates, including for PHP. By default, the official 14.04 repos only include PHP 5.5—if you're running PHP 7.1 here, you must have installed it from a third-party PPA (like the popular ondrej/php repo).

Whether an upgrade to PHP 7.2 would happen (if you ran apt-get upgrade) depends on that PPA's configuration:

  • If the PPA is set to provide the latest PHP versions, it might push 7.2 as an update for 7.1.
  • But since Ubuntu 14.04 is EOL, many third-party PPAs have also dropped support for it, so you might not even see PHP 7.2 packages available in the first place.

Newer Ubuntu versions (context for comparison)

For supported Ubuntu releases (like 16.04/18.04), the official repos lock PHP to a specific major version (e.g., 16.04 has PHP 7.0, 18.04 has PHP 7.2). If you're running PHP 7.1 on these versions, again you're using a third-party PPA. Upgrades to 7.2 would only occur if the PPA is configured to offer that version as an update, and you run an upgrade command.

How to prevent unintended PHP version upgrades

If you want to stick with PHP 7.1 and avoid accidental upgrades, you can lock the PHP packages to their current version using:

sudo apt-mark hold php7.1 php7.1-common php7.1-cli

This will prevent apt-get upgrade from updating these packages until you remove the hold with sudo apt-mark unhold [package-name].


内容的提问来源于stack exchange,提问作者Naga Vamsi Krishna Chalasani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:37:04