Installing PHP 8.0 Beta 1 on Ubuntu 20.04

PHP 8 is on its way and we wanted to have the opportunity to work with it for some of our future expansions at (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 ( 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.


These instructions were generated using a VM with a fresh copy of “bento/ubuntu20.04”.

First, we need to download the beta tarball.

vagrant@vagrant:~$ wget
--2020-08-04 21:12:31--
Resolving (, 2604:a880:800:10::2dd:1
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16860590 (16M) [application/x-gzip]
Saving to: ‘php-8.0.0beta1.tar.gz’

php-8.0.0beta1.tar.gz                             100%[===>]  16.08M  5.78MB/s    in 2.8s    

2020-08-04 21:12:34 (5.78 MB/s) - ‘php-8.0.0beta1.tar.gz’ saved [16860590/16860590]

Next, we’ll extract the file and cd into the newly-created directory.

vagrant@vagrant:~$ tar -xzf php-8.0.0beta1.tar.gz
vagrant@vagrant:~$ cd php-8.0.0beta1

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.

vagrant@vagrant:~/php-8.0.0beta1$ sudo apt-get update
sudo apt-get install -y pkg-config \
gcc \
libxml2-dev \
libsqlite3-dev \
apache2 \

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.

./configure \
--with-apxs2=/usr/bin/apxs2 \
--enable-zts \
--build=x86_64-linux-gnu \
--prefix=/usr \
--includedir=/usr/include \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc \
--localstatedir=/var \
--libdir=/usr/lib/x86_64-linux-gnu \
--libexecdir=/usr/lib/x86_64-linux-gnu \
--prefix=/usr \
--enable-cli \
--disable-cgi \
--disable-phpdbg \
--with-config-file-path=/etc/php/apache2 \
--with-config-file-scan-dir=/etc/php/apache2/conf.d \
--build=x86_64-linux-gnu \
--host=x86_64-linux-gnu \
--config-cache \
--libdir=\\/usr/lib/php \
--libexecdir=\\/usr/lib/php \
--datadir=\\/usr/share/php \
--sysconfdir=/etc \
--localstatedir=/var \

When we run the command above the script will verify that everything is set up correctly and then end with the following.

Generating files
configure: updating cache config.cache
configure: patching main/
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
|                        *** WARNING ***                             |
|                                                                    |
| You have built PHP for Apache's current non-threaded MPM.          |
| If you change Apache to use a threaded MPM you must reconfigure    |
| PHP with --enable-zts                                              |
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |

Thank you for using PHP.

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.

vagrant@vagrant:~/php-8.0.0beta1$ make
/bin/bash /home/vagrant/php-8.0.0beta1/libtool --silent --preserve-dup-deps --mode=compile x86_64-linux-gnu-gcc -Iext/date/lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DHAVE_TIMELIB_CONFIG_H=1 -Iext/date/ -I/home/vagrant/php-8.0.0beta1/ext/date/ -DPHP_ATOM_INC -I/home/vagrant/php-8.0.0beta1/include -I/home/vagrant/php-8.0.0beta1/main -I/home/vagrant/php-8.0.0beta1 -I/home/vagrant/php-8.0.0beta1/ext/date/lib -I/usr/include/libxml2 -I/home/vagrant/php-8.0.0beta1/TSRM -I/home/vagrant/php-8.0.0beta1/Zend  -D_REENTRANT -pthread  -I/usr/include -g -O2 -fvisibility=hidden -pthread -Wall -Wextra -Wno-strict-aliasing -Wno-implicit-fallthrough -Wno-unused-parameter -Wno-sign-compare -Wno-clobbered -DZTS -DZEND_SIGNALS   -c /home/vagrant/php-8.0.0beta1/ext/date/php_date.c -o ext/date/php_date.lo 

Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.

Build complete.
Don't forget to run 'make test'.

Once this process has completed we need to run sudo make install to install PHP 8 into the system.

vagrant@vagrant:~/php-8.0.0beta1$ sudo make install
Installing PHP SAPI module:       apache2handler
/usr/share/apache2/build/ SH_LIBTOOL='/usr/share/apr-1.0/build/libtool' /usr/lib/apache2/modules
/usr/share/apr-1.0/build/libtool --mode=install install /usr/lib/apache2/modules/
libtool: install: install .libs/ /usr/lib/apache2/modules/
libtool: install: install .libs/libphp.lai /usr/lib/apache2/modules/
libtool: warning: remember to run 'libtool --finish /home/vagrant/php-8.0.0beta1/libs'
chmod 644 /usr/lib/apache2/modules/
[preparing module `php' in /etc/apache2/mods-available/php.load]
Enabling module php.
To activate the new configuration, you need to run:
  systemctl restart apache2
Installing shared extensions:     /usr/lib/php/extensions/no-debug-zts-20190128/
Installing PHP CLI binary:        /usr/bin/
Installing PHP CLI man page:      /usr/share/man/man1/
Installing build environment:     \/usr/lib/php/build/
Installing header files:          /usr/include/php/
Installing helper programs:       /usr/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/share/man/man1/
  page: phpize.1
  page: php-config.1
/home/vagrant/php-8.0.0beta1/build/shtool install -c ext/phar/phar.phar /usr/bin/phar.phar
ln -s -f phar.phar /usr/bin/phar
Installing PDO headers:           /usr/include/php/ext/pdo/

Now we can run the php command-line program to view the current version.

vagrant@vagrant:~/php-8.0.0beta1$ php -v
PHP 8.0.0beta1 (cli) (built: Aug 11 2020 13:19:05) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies

Setting Up Apache

Because we want to run PHP in Apache we need to create a new configuration.

sudo vi /etc/apache2/conf-available/php.conf

Which we will need to fill with the following so Apache will know to pass “.php” files to PHP to process.

<FilesMatch \.php$>
SetHandler application/x-httpd-php

Now we need to use a2enconf to enable the configuration we just created.

vagrant@vagrant:~/php-8.0.0beta1$ sudo a2enconf php
Enabling conf php.
To activate the new configuration, you need to run:
  systemctl reload apache2

To make sure we didn’t make a mistake somewhere we’ll run a configtest.

vagrant@vagrant:~/php-8.0.0beta1$ sudo apache2ctl configtest
Syntax OK

Because that passed we can finally restart Apache so it will start using PHP 8.

vagrant@vagrant:~/php-8.0.0beta1$ sudo systemctl restart apache2

To demo this let’s create a quick phpinfo file.

sudo vi /var/www/html/phpinfo.php

When we check the file we can see that we’re getting the correct version of PHP!

PHP 8 PHPinfo

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.