5

I'm using the Amazon Linux AMI and I uninstall PHP 5.6 and some extensions and then install PHP 7.0 and some extensions. This all works fine for a few weeks and then suddenly PHP 5.6 and the extensions I had before get installed again without me doing anything (as far as I can tell) to cause this. This seems to be happening randomly on some of my servers but not others.

Here is my YUM log:

Apr 03 14:58:53 Erased: php56-5.6.30-1.133.amzn1.x86_64
Apr 03 14:58:53 Erased: php56-mysqlnd-5.6.30-1.133.amzn1.x86_64
Apr 03 14:58:53 Erased: php56-pdo-5.6.30-1.133.amzn1.x86_64
Apr 03 14:58:53 Erased: php56-xml-5.6.30-1.133.amzn1.x86_64
Apr 03 14:58:53 Erased: php56-cli-5.6.30-1.133.amzn1.x86_64
Apr 03 14:58:53 Erased: php56-jsonc-1.3.6-1.19.amzn1.x86_64
Apr 03 14:58:53 Erased: php56-common-5.6.30-1.133.amzn1.x86_64
Apr 03 14:58:53 Erased: php56-process-5.6.30-1.133.amzn1.x86_64
Apr 03 14:59:12 Installed: php70-json-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:12 Installed: php70-process-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:12 Installed: php70-cli-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:12 Installed: php70-xml-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:12 Installed: php70-common-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-pdo-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-pecl-igbinary-1.2.2-0.1.20151217git2b7c703.5.amzn1.x86_64
Apr 03 14:59:13 Installed: libXpm-3.5.10-2.9.amzn1.x86_64
Apr 03 14:59:13 Installed: libwebp-0.3.0-3.5.amzn1.x86_64
Apr 03 14:59:13 Installed: 12:aspell-0.60.6-12.7.amzn1.x86_64
Apr 03 14:59:13 Installed: libmcrypt-2.5.8-9.1.2.amzn1.x86_64
Apr 03 14:59:13 Installed: libmemcached-1.0.16-5.8.amzn1.x86_64
Apr 03 14:59:13 Installed: libtool-ltdl-2.4.2-20.4.8.3.31.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-mcrypt-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-pecl-memcached-3.0.0-0.1.20160217git6ace07d.2.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-pspell-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-gd-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-mysqlnd-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-intl-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-mbstring-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-opcache-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-soap-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-zip-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:13 Installed: php70-xmlrpc-7.0.16-1.21.amzn1.x86_64
Apr 03 14:59:51 Updated: 1:openssl-1.0.1k-15.99.amzn1.x86_64
Apr 03 14:59:52 Updated: krb5-libs-1.14.1-27.41.amzn1.x86_64
Apr 03 14:59:52 Installed: libkadm5-1.14.1-27.41.amzn1.x86_64
Apr 03 14:59:52 Installed: libverto-devel-0.2.5-4.9.amzn1.x86_64
Apr 03 14:59:52 Installed: libcom_err-devel-1.42.12-4.40.amzn1.x86_64
Apr 03 14:59:52 Installed: zlib-devel-1.2.8-7.18.amzn1.x86_64
Apr 03 14:59:52 Installed: keyutils-libs-devel-1.5.8-3.12.amzn1.x86_64
Apr 03 14:59:52 Installed: libsepol-devel-2.1.7-3.12.amzn1.x86_64
Apr 03 14:59:52 Installed: libselinux-devel-2.1.10-3.22.amzn1.x86_64
Apr 03 14:59:52 Installed: krb5-devel-1.14.1-27.41.amzn1.x86_64
Apr 03 14:59:52 Installed: 1:openssl-devel-1.0.1k-15.99.amzn1.x86_64
Apr 03 14:59:52 Installed: mysql55-devel-5.5.54-1.16.amzn1.x86_64
Apr 03 14:59:52 Installed: mysql-devel-5.5-1.6.amzn1.noarch
Apr 03 15:00:06 Updated: glibc-2.17-157.169.amzn1.x86_64
Apr 03 15:00:10 Updated: glibc-common-2.17-157.169.amzn1.x86_64
Apr 03 15:00:10 Installed: mpfr-3.1.1-4.14.amzn1.x86_64
Apr 03 15:00:10 Installed: libmpc-1.0.1-3.3.amzn1.x86_64
Apr 03 15:00:10 Installed: cpp48-4.8.3-9.111.amzn1.x86_64
Apr 03 15:00:10 Installed: libgomp-4.8.3-9.111.amzn1.x86_64
Apr 03 15:00:10 Installed: kernel-headers-4.4.51-40.60.amzn1.x86_64
Apr 03 15:00:10 Installed: glibc-headers-2.17-157.169.amzn1.x86_64
Apr 03 15:00:10 Installed: glibc-devel-2.17-157.169.amzn1.x86_64
Apr 03 15:00:11 Installed: gcc48-4.8.3-9.111.amzn1.x86_64
Apr 03 15:00:11 Installed: gcc-4.8.3-3.20.amzn1.noarch
Apr 03 15:04:31 Installed: sysstat-9.0.4-27.10.amzn1.x86_64
Apr 03 15:07:45 Installed: newrelic-repo-5-3.noarch
Apr 03 15:07:53 Installed: newrelic-sysmond-2.3.0.132-1.x86_64
Apr 03 15:08:29 Installed: newrelic-php5-common-7.1.0.187-1.noarch
Apr 03 15:08:29 Installed: newrelic-daemon-7.1.0.187-1.x86_64
Apr 03 15:08:29 Installed: newrelic-php5-7.1.0.187-1.x86_64
Apr 03 15:09:18 Installed: python26-2.6.9-2.88.amzn1.x86_64
Apr 03 15:09:18 Installed: python26-libs-2.6.9-2.88.amzn1.x86_64
Apr 03 15:09:18 Installed: python26-backports-1.0-3.14.amzn1.x86_64
Apr 03 15:09:18 Installed: python26-backports-ssl_match_hostname-3.4.0.2-1.12.amzn1.noarch
Apr 03 15:09:18 Installed: python26-setuptools-12.2-1.32.amzn1.noarch
Apr 03 15:09:18 Installed: logentries-1.4.41-1484859727.x86_64
Apr 03 15:09:26 Installed: logentries-daemon-0.8.6-1.x86_64
Apr 04 08:34:19 Erased: newrelic-php5-7.1.0.187-1.x86_64
Apr 04 08:34:23 Installed: newrelic-php5-7.1.0.187-1.x86_64
Apr 04 10:04:04 Erased: newrelic-php5-7.1.0.187-1.x86_64
Apr 04 10:04:08 Installed: newrelic-php5-7.1.0.187-1.x86_64
Apr 05 09:07:39 Erased: newrelic-php5-7.1.0.187-1.x86_64
Apr 05 09:07:43 Installed: newrelic-php5-7.1.0.187-1.x86_64
Apr 26 06:49:46 Erased: newrelic-php5-7.1.0.187-1.x86_64
Apr 26 06:49:50 Updated: newrelic-php5-common-7.2.0.191-1.noarch
Apr 26 06:49:50 Updated: newrelic-daemon-7.2.0.191-1.x86_64
Apr 26 06:49:50 Installed: newrelic-php5-7.2.0.191-1.x86_64
Apr 26 12:29:52 Erased: newrelic-php5-7.2.0.191-1.x86_64
Apr 26 12:29:55 Installed: newrelic-php5-7.2.0.191-1.x86_64
Apr 26 12:53:07 Installed: php56-jsonc-1.3.6-1.19.amzn1.x86_64
Apr 26 12:53:07 Installed: php56-cli-5.6.30-1.133.amzn1.x86_64
Apr 26 12:53:07 Installed: php56-xml-5.6.30-1.133.amzn1.x86_64
Apr 26 12:53:07 Installed: php56-common-5.6.30-1.133.amzn1.x86_64
Apr 26 12:53:08 Installed: php56-process-5.6.30-1.133.amzn1.x86_64
Apr 26 12:53:08 Installed: php56-pdo-5.6.30-1.133.amzn1.x86_64
Apr 26 12:53:08 Installed: php56-mysqlnd-5.6.30-1.133.amzn1.x86_64
Apr 26 12:53:08 Installed: php56-5.6.30-1.133.amzn1.x86_64

So PHP 5.6 was erased on 3 April and then installed again on 26 April. However the website only "switched" back to PHP 5.6 on 30 April.

On another server I have this log which shows that some updates were also kicked off automatically:

Apr 30 04:14:00 Updated: nspr-4.13.1-1.0.39.amzn1.x86_64
Apr 30 04:14:00 Updated: nss-util-3.28.4-1.0.52.amzn1.x86_64
Apr 30 04:14:00 Updated: nss-sysinit-3.28.4-1.0.78.amzn1.x86_64
Apr 30 04:14:00 Updated: nss-3.28.4-1.0.78.amzn1.x86_64
Apr 30 04:14:00 Updated: 32:bind-libs-9.8.2-0.62.rc1.54.amzn1.x86_64
Apr 30 04:14:01 Updated: 32:bind-utils-9.8.2-0.62.rc1.54.amzn1.x86_64
Apr 30 04:14:01 Updated: nss-tools-3.28.4-1.0.78.amzn1.x86_64
Apr 30 04:14:55 Installed: php56-jsonc-1.3.6-1.19.amzn1.x86_64
Apr 30 04:14:56 Installed: php56-cli-5.6.30-1.133.amzn1.x86_64
Apr 30 04:14:56 Installed: php56-xml-5.6.30-1.133.amzn1.x86_64
Apr 30 04:14:56 Installed: php56-common-5.6.30-1.133.amzn1.x86_64
Apr 30 04:14:56 Installed: php56-process-5.6.30-1.133.amzn1.x86_64
Apr 30 04:14:56 Installed: php56-pdo-5.6.30-1.133.amzn1.x86_64
Apr 30 04:14:56 Installed: php56-mysqlnd-5.6.30-1.133.amzn1.x86_64
Apr 30 04:14:56 Installed: php56-5.6.30-1.133.amzn1.x86_64

Does YUM on Amazon Linux have automatic updates switched on by default? If so why would it reinstall packages which I uninstalled and how can I prevent that?

Mikhail Janowski
  • 4,209
  • 7
  • 28
  • 40
  • with yum.conf you can add ignore package, so the package will never be updated unless you said so. But you need to check this because i think php 7 is never version and should not be updated anyway. – Nick Apr 30 '17 at 08:42
  • you also want to check, if php5 is installed by dependency and php7 is still present, but the webserver is loading php5. – Nick Apr 30 '17 at 08:46
  • Yes that seems to be the case, php7 is still installed but the webserver is loading php5 – Mikhail Janowski Apr 30 '17 at 09:01
  • I'll make it as answer – Nick Apr 30 '17 at 10:37
  • How do I find out which package depends on php56 and if I need that package how can I set Apache/httpd to load php7? – Mikhail Janowski Apr 30 '17 at 10:51

1 Answers1

0

From what we commented, I see PHP7 is still installed, but PHP5.6 is installed as well like dependency for something else.

If you are using PHP 7 as apache module, first thing you need to do will be to replace it.

Somewhere in /etc/httpd or /etc/apache2, there should be a file that should look something like this:

#LoadModule php5_module                 modules/libphp5.so
LoadModule php7_module                  modules/libphp7.so

Comment out php5, add / uncomment php7. Check correct paths.

Then restart Apache webserver with:

service httpd restart

or

service apache2 restart

Then, just out of curiosity, try uninstall PHP 5.6 and you probably will see the dependency.

Because you probably will need to keep PHP 5.6, check here how to froze package upgrades
https://access.redhat.com/solutions/10185

edit the /etc/yum.conf and add

exclude=php*

then you can do yum update just to check what will happen.

If this is live server that must not be stopped, be extra careful because errors in some steps might bring the webserver down.

Nick
  • 9,962
  • 4
  • 42
  • 80
  • I did uninstall PHP 5.6 and there were no dependencies. The strange thing is that it got reinstalled when I created an AMI and launched a new instance. – Mikhail Janowski Apr 30 '17 at 10:54
  • Probably you are using some LAMP image? Then install it and install PHP7 after that. I personally always prefer CentOS / Amazon Linux Minimal and put my own install script. – Nick Apr 30 '17 at 12:51
  • Did you clone your existing machine and new one installs PHP 5.6 – Nick Apr 30 '17 at 12:53
  • No I am using Amazon Linux an run my own install script. Yes after cloning it PHP 5.6 gets installed but only sometimes. I can't reproduce it. – Mikhail Janowski May 01 '17 at 11:44
  • then check if you install it by dependency somehow. ubuntu for example have phpmyadmin - it installs both php and apache2. saw something similar in centos, but can not give any example. also do `ps axf | grep yum` to see if there is some yum-related demon running. `chkconfig | grep yum` also might help. – Nick May 01 '17 at 13:28