简体   繁体   中英

Updating PHP packages on Ubuntu Server 16.04 fails

I'm using Google Cloud Compute Engine for our web servers. We run our webapps on PHP7.2 using Ondřej Surý's PPA.

We have a startup script to install all the required packages and doing the configuration:

apt install -y apache2 php7.2 php7.2-common php7.2-cli php7.2-mysql php7.2-json php7.2-opcache php7.2-readline php7.2-intl php7.2-mbstring php7.2-zip php7.2-curl php7.2-xml php7.2-memcached php7.2-imagick php7.2-bcmath php7.2-json

a2dismod php7.0
a2enmod php7.2
update-alternatives --set php /usr/bin/php7.2
update-alternatives --set phar /usr/bin/phar7.2
update-alternatives --set phar.phar /usr/bin/phar.phar7.2
update-alternatives --set phpize /usr/bin/phpize7.2
update-alternatives --set php-config /usr/bin/php-config7.2

On the inital setup of the virtual machine everything works and all the packages get installed without problems.

But when we need to install new php7.2-XXX packages or when there are updates of installed packages we always run into configuration errors like the one below:

So when we run apt -y upgrade we end up getting these errors:

Setting up php7.2-common (7.2.20-1+ubuntu16.04.1+deb.sury.org+1) ...
Internal error!
dpkg: error processing package php7.2-common (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of php7.2-curl:
 php7.2-curl depends on php7.2-common (= 7.2.20-1+ubuntu16.04.1+deb.sury.org+1); however:
  Package php7.2-common is not configured yet.

dpkg: error processing package php7.2-json (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php7.2-opcache:
 php7.2-opcache depends on php7.2-common (= 7.2.20-1+ubuntu16.04.1+deb.sury.org+1); however:
  Package php7.2-common is not configured yet.

...

Ending in:

Errors were encountered while processing:
 php7.2-common
 php7.2-json
 php7.2-opcache
 php7.2-readline
 php7.2-cli
 libapache2-mod-php7.2
 php7.2
 php7.2-bcmath
 php7.2-curl
 php7.2-gd
 php7.2-intl
 php7.2-mbstring
 php7.2-mysql
 php7.2-soap
 php7.2-xml
 php7.2-zip
E: Sub-process /usr/bin/dpkg returned an error code (1)

What I tried:

rebooting
apt autoremove
apt autoclean
apt clean
re-running our startup script

dpkg --configure php7.2-common resulted in:

Setting up php7.2-common (7.2.20-1+ubuntu16.04.1+deb.sury.org+1) ...
Internal error!
dpkg: error processing package php7.2-common (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 php7.2-common

Luckily our webapps seem to be functioning just fine. Been looking around for weeks now to find more info on these errors.

I can understand that you are currently experiencing issues while trying to install/update PHP packages, even though your instances seem to be working fine; I would firstly recommend you to force an installation in case that 'package install' was interrupted previously, please try the following command:

sudo apt-get install -f

If you are still unable to install the PHP 7.2 packages, please remove post info files of the troublesome package; you can try removing the files associated to the package in question from /var/lib/dpkg/info.

Due to the fact that you're having issues with all of php7.2, look for the files associated with it:

ls -l /var/lib/dpkg/info | grep -i php7.2

Thereafter try to moving them (temporarily) to another folder (see command example below):

sudo mv /var/lib/dpkg/info/php7.2-.* /tmp

And finally use sudo apt update and you should be able to install software as usual. Please let me know the results. I'll be waiting for your response!

Francisco Z.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM