I generally upgrade my servers with the following command:
sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'
Is there a clean way to upgrade everything except for PHP, or would it be easier just to upgrade everything and then rollback to PHP 8.2? I learned the hard way with a recent upgrade that WordPress isn't ready for PHP 8.3 (https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/), and had to do a complete fresh install of PHP:
sudo add-apt-repository --remove ppa:ondrej/php
sudo apt purge php*
sudo apt autoremove
sudo rm -rf /etc/php/8.3
sudo rm -rf /usr/lib/php
sudo apt install php php-mysql
sudo service apache2 restart
Note: Ubuntu moved to PHP 8.3 on January 18th: https://discourse.ubuntu.com/t/noble-numbat-release-schedule/35649
sudo apt-mark hold php
– Daniel T Feb 02 '24 at 05:11sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y; apt-mark hold php'
– ABuntToo Feb 02 '24 at 05:16apt-get install php=<the version you want>; apt-mark hold php
. I used apt-mark on a random package (tar) in a fresh install, and it held back the whole major.minor.patch version, including the patch version, not just the major or minor version. – Daniel T Feb 02 '24 at 05:20php | 2:8.1+92ubuntu1 | jammy | all
for PHP & jammy, butapt
will upgrade using whatever sources you've added to your system, and if that's 3rd party sources added, those will get used, so I'd check where you got it from (ie.apt policy
etc).apt mark
works on a package level (not version level). If you want to control updates; I suggest avoiding use of-y
which gives permission before you've read what you're agreeing to upgrade. I'm a desktop user, so don't retain what I read on ML's in regards PHP upgrade/intentions & dates etc.. – guiverc Feb 02 '24 at 05:33