Install PHP 8.0 for laravel


In order to install recent versions of PHP you have to add a repository to your system. Ondrej Sury maintains that repository which is why in most tutorials you have to add his repository.

To see which versions are available to your current repositories you can use the command:

Please note that the following instructions are for Linux.

To see which php modules are available, you should first find which version of Ubuntu you have. You can do that with the following command:

cat /etc/os-release

Then you can navigate to, select your version and then search for PHP. For example for Bionic, you should go here.

Alternatively you can use apt:

sudo apt-cache search php | grep ^php8.0

As PHP evolves many modules are moved to core PHP which means that you do not have to install them separately in spite of the fact that many tutorials try to do so.

Install prerequisites

System prerequisites

 sudo apt install ca-certificates apt-transport-https software-properties-common

System required PPA

Add the Ondrej Sury PPA to have access to more recent versions of PHP:

sudo add-apt-repository ppa:ondrej/php

Update the system repositories:

sudo apt update

Laravel listed requirements

Laravel 8.0 defines the following modules are requlred:

DocumentationAction needed
BCMathRequires installation
CTypeAlready included in PHP 8.0 commons
FileinfoAlready included in PHP 8.0 commons
JSONAlready included in PHP 8.0 commons
MbStringRequires installation
OpenSSLRequires installation
TokenizerAlready included in PHP 8.0 commons
XMLRequires installation

Composer requirements

You can list the composer requirements with the following command:

php composer.phar check-platform-reqs

All In One command

The following command installs all of those mentioned above. Use it at your own risk:

sudo apt install openssl php8.0 php8.0-bcmath php8.0-mbstring php8.0-xml php8.0-curl php8.0-zip php8.0-mysql

Install PHP core

Install PHP core:

sudo apt install php8.0

Install modules

Required Modules

sudo apt install php8.0-bcmath

No need to install it separately.


No need to install it separately. For more info read here.


No need to install it after version 8. For more info read here.

sudo apt install php8.0-mbstring
sudo apt install openssl

No need to install it separately.

sudo apt install php8.0-xml

Optional Modules


Although it is not listed on Laravel server requirements it is needed for composer.

sudo apt install php8.0-curl

Useful for composer:

sudo apt install php8.0-zip

Required for MySQL only:

sudo apt install php8.0-mysql