I have php version 7.1 in my Ubuntu 18.04.
PHP 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Oct 26 2019 19:28:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.33-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
I would like to install php 7.2 on it and keep both versions. Following this post I've got the follow outputs:
apt-cache pkgnames | grep php7.2
sudo apt-get install php -y
The following packages have unmet dependencies:
php : Depends: php7.2 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I have found similar errors and possible solutions in the internet. Most of them was about the content in the /etc/apt/sources.list
.
I just added the follow (uncommented): sudo gedit /etc/apt/sources.list
#deb http://archive.ubuntu.com/ubuntu bionic-security multiverse
#deb http://archive.ubuntu.com/ubuntu bionic-security universe
#deb http://archive.ubuntu.com/ubuntu bionic-updates multiverse
#deb http://archive.ubuntu.com/ubuntu bionic-updates universe
#deb http://archive.ubuntu.com/ubuntu bionic main multiverse restricted universe
#deb http://archive.ubuntu.com/ubuntu bionic-security main multiverse restricted universe
#deb http://archive.ubuntu.com/ubuntu bionic-updates main multiverse restricted universe
deb http://archive.ubuntu.com/ubuntu bionic main restricted universe
deb http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu bionic partner
I still have the same error.
And this is what I have inside the ect/php
:
And this is what I see in the apt list
ila@ila:~$ apt list php
Listing... Done
php/bionic,bionic 1:7.2+60ubuntu1 all
ila@ila:~$ rmadison
E: need at least one package name as an argument.
ila@ila:~$ rmadison php
php | 1:7.0+35ubuntu6 | xenial | all
php | 1:7.0+35ubuntu6.1 | xenial-updates | all
php | 1:7.2+60ubuntu1 | bionic | all
php | 2:7.2+69ubuntu1 | disco | all
php | 2:7.3+69ubuntu2 | eoan | all
php | 2:7.3+69ubuntu2 | focal | all
ila@ila:~$ apt list php
Listing... Done
php/bionic,bionic 1:7.2+60ubuntu1 all
ila@ila:~$ sudo apt install php
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 resolve the situation:
The following packages have unmet dependencies:
php : Depends: php7.2 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
After remove the 7.2 and 7.3 directories the error is still there. how can I solve it?
I have found an answer:
Following this post, I just did:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt 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
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
dpkg -l | grep php | tee packages.txt
(check the content)sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm
(install the basic)Then
And I still have my projects working with php7.1 and the new 7.2.
Or install some available modules
sudo apt install -y php7.2-bz2 php7.2-common php7.2-cgi php7.2-cli php7.2-dba php7.2-dev libphp7.2-embed php7.2-bcmath php7.2-fpm php7.2-gmp php7.2-mysql php7.2-tidy php7.2 php7.2-sqlite3 php7.2-json php7.2-opcache php7.2-sybase php7.2-curl php7.2-ldap php7.2-phpdbg php7.2-imap php7.2-xml php7.2-xsl php7.2-intl php7.2-zip php7.2-odbc php7.2-mbstring php7.2-readline php7.2-gd php7.2-interbase php7.2-snmp php7.2-xmlrpc php7.2-soap php7.2-pspell php7.2-pgsql php7.2-enchant php7.2-recode
If you getting error like
php7.2
php7.2-curl
libapache2-mod-php
doesn't have installable candidate or not locate any package or dependencies isphp7.2-common
Orlibcurl3
Do this . Remeber Change your package name as per your requirementsYou have to tackle in mature way. Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.
Now you have to check if aptitude can download it or not if download it follow instructions
If you have gotten any error like this
Any type on error i'm not talking about proper these errors
Try to add php package again
Now try this command
Aptitude will ask you you want to keep current version of all dependencies
Type
n
thenEnter
Aptitude will find all dependencies and ask you to install all package type
Again
Then
For centos of rhel
It will Not enabling PHP 7.2 FPM by default. NOTICE: To enable PHP 7.2 FPM in Apache2 do
This method is not only for this error you can find any of php apache2 or ubuntu system package solution using aptitude.