Installing PHP 8.0 Beta 1 on Ubuntu 20.04 (Focal Fossa)
Last Updated: Aug 4, 2020
PHP 8 is on its way and we wanted to have the opportunity to work with it for some of our future expansions at ThisProgrammingThing.com (sign up for our mailing list to learn when it launches). This guide will explain how to install a bare-bones version of PHP 8.0.0 Beta 1 on Ubuntu 20.04 (Focal Fossa).
Before we get started this should NOT be installed on a production server. This build exists to demo the new core features and doesn’t include a lot of the common features (like PDO).
What We Know So Far
As of right now, PHP 8.0 is on track to be released on November 26th, 2020. The release process is in feature freeze now and we’ll have 3 betas and 5 release candidates before we get the final version (https://wiki.php.net/todo/php80 for all the dates).
There are a lot of new features in this release including a Just-In-Time (JIT) Compiler which should lead directly to some performance improvements, named arguments that should make calling code easier to read when the called function has lots of arguments, and a match expression. We’ll be covering these in more detail in the near future.
Installing
These instructions were generated using a VM with a fresh copy of “bento/ubuntu20.04”.
First, we need to download the beta tarball.
Next, we’ll extract the file and cd into the newly-created directory.
Before we can set up our build environment we’ll need to install a couple of packages through apt-get that are required for PHP to build. We’ve included Apache so we can demo things a little easier but it’s not required.
PHP uses a “configure” script to make sure the required dependencies have been met. There are a lot of options in PHP’s configure script which can be listed by running ./configure --help. We based our initial set of options on the configuration from the Ondrej PHP repository and this set of options shouldn’t be seen as gospel.
When we run the command above the script will verify that everything is set up correctly and then end with the following.
We’re finally ready to build PHP 8. It’s done using the make command with no arguments. This can take a long time depending on the speed of our machine so we might want to start it and go do something else. We abbreviated the output as well because it’s ungainly long to even put on the internet.
Once this process has completed we need to run sudo make install to install PHP 8 into the system.
Now we can run the php command-line program to view the current version.
Setting Up Apache
Because we want to run PHP in Apache we need to create a new configuration.
Which we will need to fill with the following so Apache will know to pass “.php” files to PHP to process.
Now we need to use a2enconf to enable the configuration we just created.
To make sure we didn’t make a mistake somewhere we’ll run a configtest.
Because that passed we can finally restart Apache so it will start using PHP 8.
To demo this let’s create a quick phpinfo file.
When we check the file we can see that we’re getting the correct version of PHP!
Goodbye For Now
Hopefully, this article has been helpful for you. We’re going to continue to put out content about the new features of PHP 8 in the coming weeks so make sure you subscribe to our mailing list so you don’t miss anything.
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
Like this post? Don't forget to follow us on Twitter and Facebook for updates.