In the past I’ve written up installing various versions of PHP on new releases of Ubuntu, or for new releases of PHP. In those posts I’ve often recommended compiling PHP from scratch. However, compiling PHP from scratch is a serious chore, and keeping it up to date is even more of a serious responsibility. There are better ways.
The PPA’s by Ondřej Surý
There happens to be a developer who has been around since 2000 named Ondřej Surý. A major contributor to Ubuntu’s official PHP packages, Ondřej also produces a Personal Package Archive, or PPA, aimed at providing current and past versions of PHP for developers who need them.
One main advantage of Ondřej’s PPA is that you can install multiple versions of PHP or PHP-FPM, allowing you to run multiple versions of PHP side by side. (Matthew Weier O’Phinney has more on multiple versions on the same install).
Installing PHP Using A PPA
We want to start by adding the PPA to our list of packages. We do this using a Ubuntu command:
sudo add-apt-repository ppa:ondrej/php
Followed by the standard:
sudo apt-get update
Now we can begin installing PHP:
sudo apt-get install php7.3-cli
By default this will automatically install the following packages:
libpcre2-8-0 libsodium23 php-common php7.3-common php7.3-json php7.3-opcache php7.3-readline
You can view the full list of extensions on the PPA’s website.
How can I trust that the PPA is valid?
Trust is a serious issue, especially when you install your code and depend on a particular package or package vendor. The benefit of “rolling your own” is that you can trust yourself, and usually if not always the packages distributed by your package manager. But what about the PPA?
The answer to that is while it comes down to your own risk analysis and tolerance, Ondřej Surý is well-respected in the community and is responsible in part if not in whole for the “official” PHP releases that go into Ubuntu. If you’re using the official releases you’re using Ondřej’s work already.
There may be some organizations that don’t allow use of this PPA and that’s your choice. I use the PPA and rely upon it for my servers, and I’ve never had a problem. It’s often kept more up to date than the official binaries, and I can use more recent features of PHP without resorting to installing PHP myself from source.
Having the latest version of PHP can be tricky and time consuming, but the PPA that’s available makes it easy and simple. I recommend using the PPA for your own sites and applications.
Frustrated with your company’s development practices?
You don't have to be!
No matter what the issues are, they can be fixed. You can begin to shed light on these issues with my handy checklist.
Plus, I'll help you with strategies to approach the issues at the organization level and "punch above your weight."