Updating PHP packages on Ubuntu Server 16.04 fails - php

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.

Related

PHP7.2 install on Debian 9 (stretch) fails during package configuration

I hope I'm in the right place.
I'm running a fresh Debian 9 (stretch) system. I'm trying to install PHP7.2 (from Ondřej Surý repository). I did the requisite sudo apt-get update before beginning. I then followed the instructions on Christopher Shaw's site:
sudo apt-get install apt-transport-https lsb-release ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
I then did another sudo apt-get update After that, I proceeded to the meat of things: sudo apt-get install php7.2 Then the problems started. Here's the output:
(( -- successful stuff snipped -- ))
Processing triggers for man-db (2.7.6.1-2) ...
Setting up php7.2-common (7.2.7-1+0~20180622080745.23+stretch~1.gbpfd8e2e) ...
touch: cannot touch '/var/lib/php/modules/7.2/apache2/enabled_by_maint/calendar': No such file or directory
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-readline:
php7.2-readline depends on php7.2-common (= 7.2.7-1+0~20180622080745.23+stretch~1.gbpfd8e2e); however:
Package php7.2-common is not configured yet.
dpkg: error processing package php7.2-readline (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php7.2:
php7.2 depends on php7.2-common; however:
Package php7.2-common is not configured yet.
dpkg: error processing package php7.2 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php7.2-cli:
php7.2-cli depends on php7.2-common (= 7.2.7-1+0~20180622080745.23+stretch~1.gbpfd8e2e); however:
Package php7.2-common is not configured yet.
php7.2-cli depends on php7.2-readline; however:
Package php7.2-readline is not configured yet.
dpkg: error processing package php7.2-cli (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php7.2-json:
php7.2-json depends on php7.2-common (= 7.2.7-1+0~20180622080745.23+stretch~1.gbpfd8e2e); 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 libapache2-mod-php7.2:
libapache2-mod-php7.2 depends on php7.2-cli; however:
Package php7.2-cli is not configured yet.
libapache2-mod-php7.2 depends on php7.2-common (= 7.2.7-1+0~20180622080745.23+stretch~1.gbpfd8e2e); however:
Package php7.2-common is not configured yet.
libapache2-mod-php7.2 depends on php7.2-json; however:
Package php7.2-json is not configured yet.
dpkg: error processing package libapache2-mod-php7.2 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php7.2-opcache:
php7.2-opcache depends on php7.2-common (= 7.2.7-1+0~20180622080745.23+stretch~1.gbpfd8e2e); however:
Package php7.2-common is not configured yet.
dpkg: error processing package php7.2-opcache (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
php7.2-common
php7.2-readline
php7.2
php7.2-cli
php7.2-json
libapache2-mod-php7.2
php7.2-opcache
E: Sub-process /usr/bin/dpkg returned an error code (1)
~$
I searched and searched and searched and found nothing regarding this issue. After thrashing for almost an hour, I tried ..
sudo apt-get update
sudo apt-get autoclean
sudo apt-get clean
sudo apt-get autoremove
... then tried the process again. No joy.
I'm seriously dead in the water and completely at a loss. Does anyone have any ideas what's wrong or what I may try next?
Thanks!

Error while installing php 7.2 in ubuntu 17.04

I got this error when run below command
sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm
Reading state information... Done
E: Unable to locate package php7.2
E: Couldn't find any package by glob 'php7.2'
E: Couldn't find any package by regex 'php7.2'
E: Unable to locate package php7.2-common
E: Couldn't find any package by glob 'php7.2-common'
E: Couldn't find any package by regex 'php7.2-common'
E: Unable to locate package php7.2-cli
E: Couldn't find any package by glob 'php7.2-cli'
E: Couldn't find any package by regex 'php7.2-cli'
E: Unable to locate package php7.2-fpm
E: Couldn't find any package by glob 'php7.2-fpm'
E: Couldn't find any package by regex 'php7.2-fpm'
You need to manually add the ondrej PPA to be able to install PHP7.2 on Ubuntu 17.
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2
Or, by compiling it from the source by cloning the git repository, checking out the version that you want, make & make install
For more informations about compiling PHP from the source check out how to build/compile PHP from the source.
I had a similar problem.
This page helped me resolve it.
https://tecadmin.net/install-php-debian-9-stretch/
specifically, running these commands prior to the php install
sudo apt install ca-certificates apt-transport-https
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
Completely remove ALL versions of PHP
sudo apt-get purge 'php*'
Force update from unsigned repository:
Add this option in your sources.list (located at /etc/apt/sources.list):
deb [trusted=yes] https://deb.sury.org/ stretch main
Upgrade the current packages to the latest version:
sudo apt update
sudo apt upgrade
Install the required packages first on your system:
sudo apt install ca-certificates apt-transport-https
Then import packages signing key:
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
After that configure PPA for the PHP packages on your system:
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
Lastly, use one of the below options to install PHP of your requirements:
For installing PHP 7.2
sudo apt install php7.2-cli
For installing PHP 7.1
sudo apt install php7.1-cli
In my case a newer php was installed (7.4), so i just replaced the command with the 7.4 versions
sudo apt install php7.4 php7.4-common php7.4-cli php7.4-fpm
to know the version of php installed, use:
php --version
If you getting error like php7.2 php7.2-curl doesn't have installable candidate or not locate any package or dependencies is php7.2-common Or libcurl3 Do this . Remeber Change your package name as per your requirements
You have to tackle in mature way. Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.
apt-get install aptitude
Now you have to check if aptitude can download it or not if download it follow instructions
sudo aptitude install php7.2-curl
If you have gotten any error like this
E: Unable to locate package php7.2-curl
E: Couldn't find any package by glob 'php7.2-curl'
Any type on error i'm not talking about proper these errors
Try to add php package again
sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
Now try this command
sudo aptitude install php7.2-curl
Aptitude will ask you you want to keep current version of all dependencies
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) php7.2-curl [Not Installed]
Accept this solution? [Y/n/q/?]
Type n then Enter
Aptitude will find all dependencies and ask you to install all package type
y
Again
y
Then
systemctl restart apache2
For centos of rhel
systemctl restart httpd
It will Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm
This method is not only for this error you can find any of php apache2 or ubuntu system package solution using aptitude.
Upvote if you find your solution

After Ubuntu 18.04 upgrade php7.2-curl cannot be installed

Upgraded to 18.04 from 16.04 today using do-release-upgrade -d
During the upgrade I was informed that some packages would be removed, these included:
Remove: libperl5.22 lxc-common perl-modules-5.22 php-imagick
php7.1-curl php7.2-curl python3-certbot-nginx
I could re-install imagick and certbot without issue, but if I try to install php7.2-curl I get the message:
# apt install php7.2-curl -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php7.2-curl : Depends: php7.2-common (= 7.2.3-1ubuntu1) but 7.2.4-1+ubuntu16.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.
How can I correct the situation?
This can save you:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.2-fpm php7.2-gd php7.2-curl php7.2-mysql php7.2-dev php7.2-cli php7.2-common php7.2-mbstring php7.2-intl php7.2-zip php7.2-bcmath
Then sudo service apache2 restart
You don't need to add a new repo. Just do this and the 7.2 version will be installed. Remember to restart php and apache after. Also make sure (you've prob already done this though) to enable the new mod after:
sudo apt install php-curl
sudo a2enmod php7.2
You'll also notice probably that at the end of the install of php-curl (which installs php-curl and php7.2-curl) the following (Note that I have FPM setup, might look different if you're not using FPM):
NOTICE: Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.2-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
So do what it says:
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.2-fpm
sudo systemctl restart apache2.service
Installing libcurl4 worked for me using
apt install libcurl4
Then installed php7.2-curl, restarted apache2 without an issue.
You have to tackle in mature way. Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.
apt-get install aptitude
Now you have to check if aptitude can download it or not if download it follow instructions
sudo aptitude install php7.2-curl
If you have gotten any error like this
E: Unable to locate package php7.2-curl
E: Couldn't find any package by glob 'php7.2-curl'
Any type on error i'm not talking about proper these errors
Try to add php package again
sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
Now try this command
sudo aptitude install php7.2-curl
Aptitude will ask you you want to keep current version of all dependencies
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) php7.2-curl [Not Installed]
Accept this solution? [Y/n/q/?]
Type n then Enter
Aptitude will find all dependencies and ask you to install all package type
y
Again
y
Then
systemctl restart apache2
For centos of rhel
systemctl restart httpd
It will Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm
This method is not only for this error you can find any of php apache2 or ubuntu system package solution using aptitude.
Upvote if you find your solution

php7.2 fpm can t install redis

I have recently install php7.2 on debian
#!/bin/bash
apt-get install apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg
https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
apt-get update
apt-get install php7.2-fpm php7.2-cli php7.2-xml
apt-get install php-curl
apt-get install php7.2-mysql
# Si apache
apt install libapache2-mod-php
a2enconf php7.2-fpm
service php7.0-fpm restart
service php7.2-fpm restart
a2dismod php7.0
a2enmod php7.2
service apache2 restart
when i try to install php-redis, (for apache) i have error during install of sub library
Preparing to unpack .../php-igbinary_2.0.1-1+0~20170825111222.1+jessie~1.gbp48b058_amd64.deb ...
Unpacking php-igbinary (2.0.1-1+0~20170825111222.1+jessie~1.gbp48b058) ...
dpkg: error processing archive /var/cache/apt/archives/php-igbinary_2.0.1-1+0~20170825111222.1+jessie~1.gbp48b058_amd64.deb (--unpack):
trying to overwrite '/etc/php/7.0/mods-available/igbinary.ini', which is also in package php7.0-igbinary 2.0.1-1~dotdeb+8.1
Errors were encountered while processing:
/var/cache/apt/archives/php-igbinary_2.0.1- 1+0~20170825111222.1+jessie~1.gbp48b058_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
For repaire it, i have try to clean
apt-get purge php-redis
apt-get purge php-igbinary
apt-get clean
After i try to reinstall :
root#ns327838:~# apt-get install php7.2-redis
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'php-redis' instead of 'php7.2-redis'
The following extra packages will be installed:
php-igbinary
The following NEW packages will be installed:
php-igbinary php-redis
0 upgraded, 2 newly installed, 0 to remove and 66 not upgraded.
Need to get 326 kB of archives.
After this operation, 2,317 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://packages.sury.org/php/ jessie/main php-igbinary amd64 2.0.1-1+0~20170825111222.1+jessie~1.gbp48b058 [43.4 kB]
Get:2 https://packages.sury.org/php/ jessie/main php-redis amd64 4.0.0-1+0~20180412074203.5+jessie~1.gbp24a357 [282 kB]
Fetched 326 kB in 0s (654 kB/s)
(Reading database ... 62943 files and directories currently installed.)
Preparing to unpack .../php-igbinary_2.0.1-1+0~20170825111222.1+jessie~1.gbp48b058_amd64.deb ...
Unpacking php-igbinary (2.0.1-1+0~20170825111222.1+jessie~1.gbp48b058) ...
dpkg: error processing archive /var/cache/apt/archives/php-igbinary_2.0.1-1+0~20170825111222.1+jessie~1.gbp48b058_amd64.deb (--unpack):
trying to overwrite '/etc/php/7.0/mods-available/igbinary.ini', which is also in package php7.0-igbinary 2.0.1-1~dotdeb+8.1
Selecting previously unselected package php-redis.
Preparing to unpack .../php-redis_4.0.0-1+0~20180412074203.5+jessie~1.gbp24a357_amd64.deb ...
Unpacking php-redis (4.0.0-1+0~20180412074203.5+jessie~1.gbp24a357) ...
Errors were encountered while processing:
/var/cache/apt/archives/php-igbinary_2.0.1-1+0~20170825111222.1+jessie~1.gbp48b058_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Have you got idea ?
Thank you in advance

Ubuntu Server Installing PHP 7 WITHOUT Apache

I'm trying to get my server re-setup as a Lemp stack
The issue I am now running into is installing PHP 7 without Apache, since nGinx will be my webserver.
So, I've added ppa:ondrej/php. ran apt-get update, and tried to install just php7.0 via apt-get install php7.0
--nodeps flag does not work, as I am on Ubuntu 15.10
And I am presented with:
The following extra packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.0 libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libqdbm14
php-common php-readline php7.0 php7.0-cli php7.0-common php7.0-json
php7.0-opcache php7.0-readline
Suggested packages:
apache2-doc apache2-suexec-pristine apache2-suexec-custom php-pear
php-user-cache
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.0 libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libqdbm14
php php-common php-readline php7.0 php7.0-cli php7.0-common php7.0-json
php7.0-opcache php7.0-readline
I do not want apache anywhere near my server, so how can I install php7 without it? Short of compiling from source (as this makes it difficult at best to keep it updated)
If you just request php7.0, it'll install Apache as default. Do apt-get install php7.0-fpm and it'll install as FPM instead, leaving something like nginx up to you.
Use the command:
sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm
It will require the php7.2 dependencies in strict mode (WITHOUT apache2).
On Ubuntu 18.04 I managed to do this successfully with:
sudo apt-get install php7.2-cli
In Ubuntu 20.04, php 7.4 is the default.
Thus, without adding any PPAs, all you need is
apt install php-fpm
This will bring in a few libraries, including php-cli, but NO apache-related things.
With the following steps you can install any PHP version you want, just replace 7.4 with your desired version.
Also I am suggesting to install the cli package because I assume you dont want to have fpm installed. Otherwise you can install php7.4-fpm instead.
Install ppa:ondrej/php repositories
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
Install PHP
sudo apt install php7.4-cli
You will get the following:
The following additional packages will be installed:
php-common php7.4-common php7.4-json php7.4-opcache php7.4-readline

Categories