I'm changing php versions, successfully, but only for a while, then it rolls back.

I have several php versions installed:

leonid@DevSSD:~$ sudo a2enmod php
php5.6  php7.0  php7.1  php7.2  

So, I do

sudo a2dismod php7.2
sudo a2enmod php5.6
sudo systemctl restart apache2

Php page with php_info() changed, versions changed correctly. I don't care about cli, don't need it yet.

After a while php changed back to 7.2; I don't known why or who changed it. I don't know what log file to check.

I really multiple php versions, at least 5 and 7 latest release.

Holding the package does not help, because I have them all the different php versions and modules I need installed. Nothing is being changed or updated by APT between the version changes.

No, this is not a duplicate of the suggested question, because I have followed a guide, and can make any php version default, but for a little while, I have had a problem somewhere in configs.

  • Yes you can see here
    – Vijay
    Dec 5, 2018 at 17:15
  • @Hobbyist thats what I use to install
    – LeonidMew
    Dec 5, 2018 at 17:17
  • @PRATAP Hope not a person, just some system package do it
    – LeonidMew
    Dec 5, 2018 at 17:18
  • It do it again, without my any interaction. First I check it still 5.6, then 2 glasses of wine, and right after that when checked again - its 7.2
    – LeonidMew
    Dec 5, 2018 at 17:23

1 Answer 1


Install the version you want If you want that package version not to change. Put the package on hold:

echo "<package-name> hold" | sudo dpkg --set-selections

Remove the hold:

echo "<package-name> install" | sudo dpkg --set-selections
  • Another way to hold the package's version: sudo apt-mark hold <package-name>
    – pa4080
    Dec 5, 2018 at 17:25
  • 3
    There were no package updates, something else take place. Are you sure hold package helps? All versions of packages present at same time. Few php versions and lots of php modules installed, with different versions. Only config changes
    – LeonidMew
    Dec 5, 2018 at 17:30
  • I used it for some other application.
    – Vijay
    Dec 5, 2018 at 17:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.