How to run updates on Ubuntu command line without upgrading PHP

I run an Ubuntu server on 16.04 using LAMP stack. I ran into an issue last week when updating using:

  sudo apt update

Basically PHP was automatically upgraded from 7.4 to 8.0 during the upgrade & this broke some functionality on my websites. Is there a way to tell my server not to update PHP when I run the above command? In the future I never want to upgrade PHP as this can cause issues to my websites.


Solution 1:

Try to Pin the packet before runing update: sudo apt-mark hold