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.
2
Answers
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.
I really recommend installing PHP via Ondřej Surý’s PPA
You will be able not only to install PHP but also to install most of its popular PECL packages.