DEV Community

loading...

Install PHP 8 on Ubuntu

neoan
Passionate generalist conquering the web one project at a time. Whether authoring libraries for node, JS, PHP, or Rust, I am always on the lookout for better solutions to common problems.
Originally published at blua.blue Updated on ・1 min read

Installation

If you are running php7.x, it's likely you are already using the following repository. If not, here are the commands:

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Now let's install PHP8:

sudo apt update

APACHE

sudo apt install php8.0 libapache2-mod-php8.0

When you are done installing your extensions, don't forget to restart with sudo service apache2 restart
(or sudo systemctl restart apache2 )

NGINX

sudo apt install php8.0-fpm

When you are done installing your extensions, don't forget to restart with sudo service nginx restart
(or sudo systemctl restart nginx )

Extensions

Before we give it a spin, let's install some common extensions we might need.
(The following list is based on neoan3 requirements, feel free to check what you need for the setup of your choice)

sudo apt install php8.0-{mysql,zip,xml,curl} or install them one-by-one in this format:

sudo apt install php8.0-xml (see a list here)

Happy hacking!

Discussion (0)

Forem Open with the Forem app