error installing php dependencies on ubuntu

cc flag

I have a vps with linux ubuntu 20.04 LTS installed, I also installed the lamp stack to upload my web projects, php with version 7.4, now I need to install some more php libraries for example: php-gd so run the command:

sudo apt-get install php7.4-gd

but when installing I get the following error: php7.4-cli : Depends: php7.4-common (= 7.4.3-4ubuntu2.18) but 7.4.3-4ubuntu2.17 is to be installed

and actually it won't let me install anything else, because it always throws me that error.. any idea how to solve this?

mt flag

First Install software-properties-common package on Ubuntu

sudo apt-get update 
sudo apt-get install software-properties-common

You can try adding ondrej/php PPA for PHP 7.4 in your Ubuntu 20.04 LTS

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

Once update completes, run the following to install PHP 7.4

sudo apt install -y \
php7.4 \
php7.4-bcmath \
php7.4-bz2 \
php7.4-cgi \
php7.4-cli \
php7.4-curl \
php7.4-fpm \
php7.4-gd \
php7.4-gettext \
php7.4-intl \
php7.4-ldap \
php7.4-mbstring \
php7.4-mysql \
php7.4-opcache \
php7.4-pgsql \
php7.4-soap \
php7.4-xml \

Once Installation completes you can use the following commands to check, If PHP 7.4 Installed or not php -v

FeRcHo avatar
cc flag
when i run: sudo apt-get install software-properties-common,i also get the mentioned error
Basant Mandal avatar
mt flag
@FeRcHo Try using these commands first `sudo apt-get purge php7.* && sudo apt-get autoclean && sudo apt-get autoremove` Once it completes, Try the commands provided in the solution. **sudo apt-get purge** - It removes the package as well as its configuration files **sudo apt-get autoclean** - It cleans obsolete deb-packages. **sudo apt-get autoremove** - It removes orphaned packages which are no longer needed
ar flag

Check /etc/apt/sources.list and see if it contains a line this:

deb http://... focal-security main restricted universe multiverse

The line make look slightly different, but most important is that you have the focal-security repository enabled, since version 7.4.3-4ubuntu2.18 is available there.

Then update the repo apt update and try again apt install php7.4-gd.

FeRcHo avatar
cc flag
I don't have that line added, what should I do? should i register it?
Wanted avatar
ar flag
Yes, add: `deb focal-security main restricted universe multiverse` and run `apt update` and `apt install php7.4-gd`
I sit in a Tesla and translated this thread with Ai:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.