L o a d i n g

I've seen a lot of tutorials on installing PHP 8 on Ubuntu, Debian, but none of them seem to work anymore maybe they do work on Ubuntu itself but other Debian distros I've tried didn't work. So I ended up compiling it myself and that's what I'm going to show you in this guide.

Setting up the environment

Make sure you have gcc installed which comes pre-installed in almost any Linux distro out there. The next thing is to install build tools.

sudo apt-get install build-essential autoconf re2c bison

This may not be everything we are going to need but if you find an error that says package 'package-name' not found just install it by running apt-get install lib<package-name>-dev. If you're unsure of the package name type lib followed by incomplete package name, then hit tab to autocomplete.

Getting PHP

Go to php.net and download the latest release. Once downloaded extract by

tar -xzf php-8.0.3.tar.gz
cd php-8.0.3


The next step is to configure, tell gcc which extension we want to include

./configure --with-openssl\

If all goes well you should see this

| 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.

If not, it's probably because you have a library missing which you can install by running apt-get install lib<package-name>-dev


Sometimes you may want to check how many cores your CPU has


And then you can use that number to make builds faster with the -j flag.

make -j2

This will use 2 cores to build. Be patient and after you see build complete on the console install the binaries in --prefix destination (provided during configuration)

sudo make install

After it's done confirm by

php -v
PHP 8.0.3 (cli) (built: Mar  24 2021 15:37:13) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies

Almost done, now depending on the environment copy the php.ini-production or php.ini-development to the --with-config-file-path you provided during configuration.

Now you have the latest version of PHP. I'll write another article on how to upgrade but in the meantime Happy Coding!

Tags :
Writer at Flixtechs Given Ncube's picture
Given Ncube