0

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?

FeRcHo
  • 103
  • 5

2 Answers2

0

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.

Wanted
  • 281
  • 1
  • 5
  • I don't have that line added, what should I do? should i register it? – FeRcHo Apr 03 '23 at 15:09
  • Yes, add: `deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse` and run `apt update` and `apt install php7.4-gd` – Wanted Apr 12 '23 at 19:32
0

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 \
php7.4-zip

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

  • when i run: sudo apt-get install software-properties-common,i also get the mentioned error – FeRcHo Apr 03 '23 at 15:12
  • @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 – Basant Mandal Apr 04 '23 at 05:15