Search code examples
phpubuntuubuntu-18.04

Unable to loacate package when trying to install mbstring for php7.4


I've got a webserver running a few different php versions. Whereas php 8.2 has mbstring installed, I need to install mbstring for php 7.4 as well. However, when trying to install it using sudo apt-get install php7.4-mbstring I receive the following error:

E: Unable to locate package php7.4-mbstring
E: Couldn't find any package by glob 'php7.4-mbstring'
E: Couldn't find any package by regex 'php7.4-mbstring'

I have tried running sudo apt-get update and sudo apt-get upgrade but the installation still fails. I've also tried adding the "universe" repository as described in this thread: Cannot install php-mbstring on ubuntu 18.04 In addition I've also added the ondrej repository sudo add-apt-repository ppa:ondrej/php but again with the result being the same.

None of the proposed answers in the following threads have lead to a solution so far:

The server is running Ubuntu 18.04


Solution

  • Ubuntu 18.04 LTS as well as PHP 7.4 have reached EOL (end of life). That means they are no longer supported and you should upgrade.

    See the Ubuntu release cycle and PHP Supported Versions. Ubuntu 18.04 reached EOL on May 31, 2023 and PHP 7.4 already on Nov 28, 2022!

    The PPA supplied by the wonderful Ondřej Surý only supplies packages for active Ubuntu versions. On his website he states "Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided."

    I recently however had success in updating PHP 7.4 on a Ubuntu 20.04 LTS machine, which is still supported. There is no guarantee how long this will be supported, though.

    You need to upgrade to a supported version for your app to continue functioning and to be safe from security issues.