1

I'm trying to install php on Ubuntu 22.10, I used to be able to do "apt install php" and be done with it but now I can't for some reason?

All I get when I run install php is this:

root@backups:/# apt install php
Reading package lists... Done
Building dependency tree... Done
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:
 php8.2 : Depends: libapache2-mod-php8.2 but it is not installable or
                   php8.2-fpm but it is not installable or
                   php8.2-cgi but it is not installable
          Depends: php8.2-common but it is not installable
E: Unable to correct problems, you have held broken packages.

I don't really care which version of php I can get as long as it's 7 or 8, I've tried many guides, they all tell you to either add this (http://ppa.launchpad.net/ondrej/php/ubuntu/pool/main/p/php8.1/) repository (which doesn't work) or just run apt install, which doesn't work either. Or some variation of that.

I can install any program except for PHO or PHP-related dependences or packages.

When installing a dependence I get:

root@backups:/# sudo apt install php8.1-fpm
Reading package lists... Done
Building dependency tree... Done
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:
 php8.1-fpm : Depends: php8.1-common (= 8.1.18-1+ubuntu20.04.1+deb.sury.org+1) but 8.1.7-1ubuntu3.3 is to be installed
E: Unable to correct problems, you have held broken packages.

Adding ppa:ondrej/php repository results in:

root@backups:/var/www/snipeit# sudo add-apt-repository ppa:ondrej/nginx-mainline
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'deb https://ppa.launchpadcontent.net/ondrej/nginx-mainline/ubuntu/ kinetic main'
Description:
This branch follows latest NGINX Mainline packages compiled against latest OpenSSL for HTTP/2 and TLS 1.3 support.

BUGS&FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#bug-reporting

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating: https://donate.sury.org
More info: https://launchpad.net/~ondrej/+archive/ubuntu/nginx-mainline
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.

Continuing just throws me an error when updating

E: The repository 'https://ppa.launchpadcontent.net/ondrej/nginx-mainline/ubuntu kinetic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

I'm guessing this problem is due to 22.10 being fairly new, but I've always installed the latest versions of Ubuntu and never had an issue with installing programs, I thought that was the whole point of Linux, stable and reliable.

I can reinstall an older version, but I'd like to avoid that if possible, since I have more services running on that machine.

Alex
  • 37
  • 5
  • You might want to use this source instead https://deb.sury.org/ – Marcin Orlowski Apr 27 '23 at 14:10
  • It doesn't work either – Alex Apr 27 '23 at 14:23
  • Have a look at https://github.com/oerdnj/deb.sury.org/issues/1662 - deb.sury.org does not support non-lts releases – Nico Haase Apr 27 '23 at 14:28
  • I would assume that you have to remove the deb.sury-packages - `8.1.18-1+ubuntu20.04.1+deb.sury.org+1` does not look like a package version that you should have installed on Ubuntu 22.10 – Nico Haase Apr 27 '23 at 14:30
  • i checked the ondrej repository and it does not have package for ubuntu 22.10 as of date.... if you wish to install php on 22.10 then you can [compile it from source](https://thephp.website/en/issue/how-to-compile-php/) - _but bugs might bite_ or better downgrade OS to 22.04 LTS ... – Anant V Apr 27 '23 at 15:02

2 Answers2

-1

I really recommend installing PHP via Ondřej Surý's PPA

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

You will be able not only to install PHP but also to install most of its popular PECL packages.

rogervila
  • 974
  • 1
  • 10
  • 27
-1

Moral of the story: Don't use Bleeding Edge technology to deploy servers. Stay on LTS releases.

Apparently the PHP Library has not been compiled for Ubuntu 22.10 yet, Just downgrade to 22.04 LTS and it works first time, you don't even need to add any repos, just apt install it.

The solution @rogervila providad works too, and you may be able to get it working on ubuntu 22.10, but it's just easier to downgrade to an LTS release.

Alex
  • 37
  • 5
  • "the PHP Library has not been compiled for Ubuntu 22.10 yet" - of course it has been. https://packages.ubuntu.com/kinetic/php/ lists tons of PHP packages that are part of Ubuntus own repositories – Nico Haase Apr 28 '23 at 07:25
  • "of course it has been" I was referring to ppa:ondrej/php repository. It has no release file for Ubuntu 22.10. ``` E: The repository 'https://ppa.launchpadcontent.net/ondrej/nginx-mainline/ubuntukinetic Release' does not have a Release file. ``` – Alex Apr 29 '23 at 17:05
  • That comment looks pretty strange to me - why does it refer to nginx to install PHP packages? Also, the **original** package sources for Ubuntu 22.10 contain all neccessary PHP packages. If you want to use any **third-party** package source, choose one that is supported – Nico Haase May 02 '23 at 07:08
  • Once again, I'm referring to ppa:ondrej/php repository, not the ubuntu default one. The issue has been resolved, ppa:ondrej/php repository has no releases for Ubuntu 20.10 since it only supports LTS releases officially. End of the story, if you want to use the ppa:ondrej/php repository you need to get on an LTS release. There's nothing else to discuss. – Alex May 03 '23 at 15:30