(Please see both edits). Ubuntu 18.04, PHP 7.4.2. I would like help installing the Curl PHP package on my server. Here is the issue I'm encountering, and what I've tried so far:
When I run sudo apt-get install php-curl
, I am met with the following error:
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:
php-curl : Depends: php7.4-curl but it is not going to be installed
I followed these steps to identify and remove broken packages to try and rectify the first half.
When I run sudo apt-get install php7.4-curl
I get this error:
The following packages have unmet dependencies:
php7.4-curl : Depends: libcurl4 (>= 7.56.1) but it is not going to be installed
So I tried sudo apt-get install libcurl4
, and received this:
The following additional packages will be installed:
php7.4-fpm
The following packages will be REMOVED:
apache2 apache2-bin libapache2-mod-php libapache2-mod-php7.0
libapache2-mod-php7.4 libcurl3 python-certbot-apache python3-certbot-apache
The following NEW packages will be installed:
libcurl4 php7.4-fpm
0 upgraded, 2 newly installed, 8 to remove and 0 not upgraded.
Remv python-certbot-apache [0.31.0-1+ubuntu18.04.1+certbot+1]
Remv python3-certbot-apache [0.31.0-1+ubuntu18.04.1+certbot+1]
Remv apache2 [2.4.41-1+ubuntu16.04.1+deb.sury.org+5]
Remv libapache2-mod-php [2:7.4+75+ubuntu18.04.1+deb.sury.org+1]
Inst php7.4-fpm (7.4.4-1+ubuntu18.04.1+deb.sury.org+1 ***** The main PPA for supported PHP versions with many PECL extensions *****:18.04/bionic [amd64])
Remv libapache2-mod-php7.4 [7.4.4-1+ubuntu18.04.1+deb.sury.org+1]
Remv libapache2-mod-php7.0 [7.0.33-26+ubuntu18.04.1+deb.sury.org+1]
Remv apache2-bin [2.4.41-1+ubuntu16.04.1+deb.sury.org+5]
Remv libcurl3 [7.58.0-2ubuntu2]
Inst libcurl4 (7.58.0-2ubuntu3.8 Ubuntu:18.04/bionic-security [amd64])
Conf php7.4-fpm (7.4.4-1+ubuntu18.04.1+deb.sury.org+1 ***** The main PPA for supported PHP versions with many PECL extensions *****:18.04/bionic [amd64])
Conf libcurl4 (7.58.0-2ubuntu3.8 Ubuntu:18.04/bionic-security [amd64])
I don't understand why it wants to remove apache2, certbot, and various other important packages. Can anybody advise on how Curl can be installed without removing so many other packages?
EDIT:
I followed this guidance to remove everything related to PHP, then this to install PHP7.2 (as advise: the version that 18.04 shipped with). PHP -v
now returns PHP 7.2.29-1+ubuntu18.04.1+deb.sury.org+1
. However, I still encounter the same issues. After a recommendation to try installing with aptitude, the error message is a bit more detailed:
The following NEW packages will be installed:
libcurl4{ab} php7.4-common{a} php7.4-curl
The following packages will be REMOVED:
libonig4{u} libpcre2-8-0{u}
0 packages upgraded, 3 newly installed, 2 to remove and 0 not upgraded.
Need to get 245 kB/1,243 kB of archives. After unpacking 7,098 kB will be used.
The following packages have unmet dependencies:
libcurl3 : Conflicts: libcurl4 but 7.58.0-2ubuntu3.8 is to be installed
libcurl4 : Conflicts: libcurl3 but 7.58.0-2ubuntu2 is installed
The following actions will resolve these dependencies:
Remove the following packages:
1) apache2 [2.4.41-1+ubuntu16.04.1+deb.sury.org+5 (now)]
2) apache2-bin [2.4.41-1+ubuntu16.04.1+deb.sury.org+5 (now)]
3) libapache2-mod-php7.2 [7.2.29-1+ubuntu18.04.1+deb.sury.org+1 (bionic, now
4) libcurl3 [7.58.0-2ubuntu2 (bionic, now)]
5) python-certbot-apache [0.31.0-1+ubuntu18.04.1+certbot+1 (bionic, now)]
6) python3-certbot-apache [0.31.0-1+ubuntu18.04.1+certbot+1 (bionic, now)]
Does this information give any indication on why it wants to remove apache2 and the other modules in the list before curl/libcurl can be installed?
Edit 2:
After much fiddling and frustration (and desperation) I tried the following, as recommended on this thread:
sudo add-apt-repository main
sudo add-apt-repository universe
sudo add-apt-repository restricted
sudo add-apt-repository multiverse
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php-curl
The output for the first four repository commands was component is already enabled for all sources.
ppa:ondrej/php was already added, as was the ondrej/apache2. I'd run sudo apt-get update
several times.
But, somehow, doing those things in that order fixed whatever the issue was, and I now have cURL functioning on my server.
apt-cache policy <package_name>
to learn the source of a specific package. Then you know which source is causing problems. – user535733 Apr 02 '20 at 15:46