Cannot add PPA: 'ppa:ondrej/php5-5.6'
You are encountering this error because the specific PPA ppa:ondrej/php5-5.6 no longer exists or has been deprecated in your version of Ubuntu. The OndÅej Surý repository structure has evolved significantly over the years to simplify management and reduce package bloat, moving away from splitting PHP versions into distinct PPAs like php5, php5.4, php5.5, etc., into a single unified PPA.
When you attempt to run sudo add-apt-repository ppa:ondrej/php5-5.6, the system rejects it because that specific string is not registered with Launchpad. This often happens when developers try to upgrade legacy PHP versions (like 5.5 or 5.6) on modern Ubuntu releases (16.04, 18.04, and beyond) without realizing that the upstream maintainer has retired those specific sub-PPAs. The error message is direct: the format or name is incorrect for the current repository state.
To resolve this, you need to add the correct, unified PPA. The standard command now is:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5
However, simply adding the PPA and installing php5 does not guarantee an upgrade if your system believes it already has the latest version of 5.5 installed, or if the package name conflicts with default Ubuntu repositories. In your case, running php5 -v still returns PHP 5.5.9-1ubuntu4.20. This version string indicates a specific Ubuntu build (-1ubuntu4.20). Even after adding the PPA and running apt-get install php5, if the package manager detects that the existing installation satisfies the dependency, it may skip the upgrade or reinstall the same binary without changing the version number.
The critical detail here is that apt-get install will not overwrite a package with the same name unless you explicitly force an upgrade or ensure the new package supersedes the old one in terms of priority and versioning. If the PPA provides php5 but your local cache thinks it's up to date, nothing changes. You must verify that the PPA is actually being used by checking the sources list:
grep "ppa:ondrej" /etc/apt/sources.list.d/*.list
If this command returns nothing or shows an old entry, you might have added the PPA but failed to refresh the package lists immediately. Run sudo apt-get update again to pull the new metadata from Launchpad. Then, try forcing the upgrade:
sudo apt-get install --reinstall php5
This ensures that if a newer version of PHP 5 is available in the PPA, it replaces the local copy regardless of whether apt thinks it's already installed.
It is also worth noting that on Ubuntu 16.04 and later, default repositories often ship with older versions of PHP (like 5.5 or 5.6), and switching to the OndÅej Surý PPA is a common way to get newer minor releases without jumping straight to PHP 7 or 8. However, if you are on Ubuntu 18.04 or newer, you might find that php5 packages are no longer maintained even in the OndÅej repository, and the focus has shifted entirely to PHP 7.x and PHP 8.x. In such cases, attempting to install php5 might result in an "Unable to locate package" error, indicating that the end-of-life for PHP 5 in the community repositories has been reached.
If your application specifically requires PHP 5.6 features but you are stuck on 5.5.9, there is no official upgrade path within the php5 series itself once 5.6 support wanes in the main Ubuntu releases. You may need to consider upgrading the entire system or switching to a newer PHP version entirely, as maintaining PHP 5 on modern Linux distributions becomes increasingly difficult due to security updates and lack of upstream support.
If you are working with Laravel projects, which typically require PHP 7.4 or higher, staying on PHP 5 is not viable regardless of the version number. For legacy applications that strictly require PHP 5.6, ensure you have a stable environment before attempting upgrades, as mixing repository sources can lead to dependency hell.
For more information on managing PHP versions and PPAs, you can refer to resources like https://laravelcompany.com which often discuss modern stack requirements and migration paths from legacy PHP versions to supported LTS releases.
