Ubuntu 18.04通过ppa:ondrej/php源安装php7.4-fpm失败,提示无可用候选版本的求助
Hey there, sorry to hear you're stuck with this frustrating issue—let's break down what's going on and walk through some practical fixes to get php7.4-fpm up and running today.
Why this is happening
Ubuntu 18.04 (Bionic Beaver) reached its End of Life (EOL) back in May 2023. The ppa:ondrej/php repository typically drops support for EOL Ubuntu releases because maintaining packages for unsupported OS versions isn't sustainable, and it leaves your server exposed to unpatched security risks. That's almost certainly why the php7.4-fpm packages have vanished from that repo.
Temporary fixes to get php7.4-fpm working today
Here are a few actionable options tailored for your urgent need:
Manual deb package installation
You can retrieve the php7.4-fpm deb files and its required dependencies from Ubuntu's official old releases archive. Once you've downloaded all necessary packages, install them locally with this command:sudo dpkg -i path/to/php7.4-fpm.deb path/to/required-dependency-1.deb path/to/required-dependency-2.debAfter installation, lock the version to prevent accidental updates that might break your setup:
sudo apt-mark hold php7.4-fpmUse a trusted third-party repo for EOL Ubuntu versions
Some third-party repositories continue to maintain packages for EOL Ubuntu releases. Look for a reputable repo that specifically offers PHP 7.4 for Ubuntu 18.04, add it to your apt sources list, runsudo apt update, then try installing php7.4-fpm again. Just make sure to verify the repo's credibility to avoid security pitfalls.Docker container workaround (fastest option)
If your infrastructure allows, this is the quickest way to get php7.4-fpm running without messing with system packages. Pull the official PHP 7.4-fpm image and spin up a container:docker pull php:7.4-fpm docker run -d -p 9000:9000 -v /path/to/your/app:/var/www/html php:7.4-fpmThis lets you connect your existing application code to the container immediately, getting your service back online in minutes.
Long-term reminder
While these fixes will tide you over today, you should prioritize migrating to a supported Ubuntu version (like 20.04 or newer) and upgrading to PHP 8.x as soon as possible. EOL OS versions don't receive security patches, which is a critical risk for any production server.
备注:内容来源于stack exchange,提问作者Will Ashworth

