Upgrade PHP version 7.4 to 8.0 on Ubuntu


To upgrade PHP 7.4 to version 8.0 on Ubuntu apache, start a terminal window and type the sudo apt install php8.0 command to install the new PHP version and type sudo a2enmod php8.0 command to enable the PHP 8.0 version and disable the older version using sudo a2dismod php7.4 command on ubuntu system.

Here are steps to upgrade the PHP 7.4 to 8.0 version on Linux Ubuntu apache via the command line:

Step 1: Update System Packages

Press ctrl+alt+t on the keyboard to start a terminal window, and type the sudo apt-get update command in it to update system packages:

sudo apt-get update

Step 2: Add the Latest PHP repository

Add the latest PHP repository to the Ubuntu server by typing the following command in the terminal window and pressing Enter.

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

Step 3: Install PHP 8 and Its Packages

To install php 8.0 version, use sudo apt install php8.0 command on Ubuntu terminal window and press Enter:

sudo apt install php8.0

Once you have installed php 8.0 in your Ubuntu system, after this, you also need to install the packages related to PHP 8.0, for this, you can use the following command on the terminal window:

sudo apt install php8.0-common php8.0-mysql php8.0-xml php8.0-xmlrpc php8.0-curl php8.0-gd php8.0-imagick php8.0-cli php8.0-dev php8.0-imap php8.0-mbstring php8.0-opcache php8.0-soap php8.0-zip php8.0-intl -y

Step 4: Enable PHP 8.0 & Disable PHP 7.4 Version

Before enabling PHP 8.0 version, you need to disable php 7.4 version in ubuntu server, type sudo a2dismod php7.4 command on terminal window and press enter:

sudo a2dismod php7.4

Next type sudo a2enmod php8.0 command on terminal window and press enter, this will enable php 8.0 version on ubuntu:

sudo a2enmod php8.0

To apply the changes, restart the Apache web server by typing the sudo service apache2 restart command on the terminal window and press Enter:

sudo service apache2 restart

Step 5: Verify PHP Version

Now type the command php -v on the terminal window and press enter and you will see on the terminal window that your php version has been upgraded:

php -v

You have upgraded php 7.4 to 8.0 version but you are still seeing the same old version on terminal window, it means that the changes in the configuration file have not been applied, Simply type the sudo update-alternatives --config php command on the terminal window and press enter, it will do the configuration on your Ubuntu for updated PHP 8.0 version:

sudo update-alternatives --config php


That’s it; In just 4 steps, you can update PHP from version 7.4 to version 8.4 using a few simple commands in an Ubuntu Linux terminal window.

Recommended Tutorials


Jaspreet Singh Ghuman

Jaspreet Singh Ghuman


Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Jassweb, Rai Chak, Punjab, India. 143518