2

I am new to using Ubuntu OS, I am trying to install PHP so that I can use the interpreter in for PHPStorm.

The commands I have used: sudo apt-get update sudo apt install php

then I get the following error

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 to resolve the situation:

The following packages have unmet dependencies.
 php : Depends: php8.1 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.


Wondering if anyone can help?

sudo apt update:

Hit:1 http://gb.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]      
Hit:3 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease               
Get:4 http://gb.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]     
Hit:5 https://dl.google.com/linux/chrome/deb stable InRelease                  
Get:6 http://gb.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:7 https://deb.nodesource.com/node_16.x focal InRelease
Get:8 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [40.8 kB]
Get:9 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [66.6 kB]
Get:10 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:11 http://gb.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [278 kB]
Get:12 http://gb.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [390 kB]
Get:13 http://gb.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [944 B]
Get:14 http://gb.archive.ubuntu.com/ubuntu focal-backports/main amd64 DEP-11 Metadata [7,980 B]
Get:15 http://gb.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.8 kB]
Fetched 1,154 kB in 1s (1,216 kB/s)                                          
Reading package lists... Done
Building dependency tree       
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.


11
  • What is your ubuntu release please?
    – nobody
    Apr 26, 2022 at 21:16
  • @nobody No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.4 LTS Release: 20.04 Codename: focal Apr 26, 2022 at 21:18
  • Please edit your question and show us sudo apt update
    – nobody
    Apr 26, 2022 at 21:38
  • @nobody added above Apr 26, 2022 at 21:42
  • 1
    @Natan yes that didn't solve the issue for me Apr 26, 2022 at 22:03

2 Answers 2

1

After installing the add-apt-repository ppa:ondrej/php PPA and updating the repositories (sudo apt update), I was not able to install PHP 8.1 on Ubuntu 20.04.4 LTS:

The following packages have unmet dependencies:
 php8.1 : Depends: libapache2-mod-php8.1 but it is not going to be installed or
                   php8.1-fpm but it is not going to be installed or
                   php8.1-cgi but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I finally succeeded with :

  1. sudo apt remove php
    but got
    The following packages have unmet dependencies: libapache2-mod-php8.1 : Depends: php8.1-cli but it is not going to be installed Depends: libpcre2-8-0 (>= 10.38) but 10.34-7 is to be installed E: Unable to correct problems, you have held broken packages.
  2. So I installed the dependancy with sudo apt install libpcre2-8-0
  3. And finally sudo apt install php8.1

The result is

$ php -v
PHP 8.1.7 (cli) (built: Jun 10 2022 12:22:48) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.7, Copyright (c), by Zend Technologies
1
  • Had a similar issue - the solution was simply to put the repository back sudo add-apt-repository ppa:ondrej/php - I'm 100% sure I've installed php 8.1 with it, but I guess that some update or something turned it of / removed it or something like that ...
    – jave.web
    Sep 7, 2023 at 22:54
-1

I used >sudo apt-get install aptitude< Then

sudo aptitude -f< Aptitude to the rescue

1
  • 1
    Maybe a bit more instruction would be more helpful? The -f only launches the aptitude UI
    – Antony
    Jan 29, 2023 at 19:05

Not the answer you're looking for? Browse other questions tagged .