Rodrigo
Rodrigo

Reputation: 371

php8.1-bcmath : Depends: php8.1-common (= 8.1.2-1ubuntu2) but 8.1.2-1ubuntu4 is to be installed

I am upgrading an image that used PHP 7.4 and now I am planning to use PHP 8.1.

However, I am getting the error

php8.1-bcmath : Depends: php8.1-common (= 8.1.2-1ubuntu2) but 8.1.2-1ubuntu4 is to be installed php8.1-fpm : Depends: php8.1-common (= 8.1.2-1ubuntu2) but 8.1.2-1ubuntu4 is to be installed

On this line

apt install php8.1-bcmath php8.1-fpm php8.1-common

What I should do to install those dependencies?

Upvotes: 7

Views: 13077

Answers (2)

Ishan Anand
Ishan Anand

Reputation: 161

I resolved the issue by running the below command in sequence:

a. The below command will remove all the php packages.

sudo apt-get purge 'php*' 

b. The below command will add the php repository

sudo add-apt-repository ppa:ondrej/php   

c. The below command will install all the latest php (in 2022, latest php package is 8.1) packages except for apache webserver packages.

sudo apt install --no-install-recommends php8.1 

If you want to install all the apache webserver packages then run the above command without --no-install-recommends

Upvotes: 7

Mmx
Mmx

Reputation: 476

php8.1-bcmath needed php8.1-common compiled for Ubuntu version 8.1.2-1ubuntu2 but you have installed php8.1-common compiled for 8.1.2-1ubuntu4 (You have newest version).

Steps:

  1. Remove php sudo apt remove php8.1-common
  2. Install php with specific asked in error message ubuntu version sudo apt install php8.1=8.1.2-1ubuntu2
  3. Install php extension fpm sudo apt-get install php8.1-fpm
  4. Install php extension bcmath sudo apt-get install php8.1-bcmath

P.s. This solution work with any Ubuntu version - sudo apt install php8.1=YOUR_VERSION_OF_ASKED_UBUNTU

Upvotes: 6

Related Questions