Upgrade to PHP8.1

Hi All. I have been trying to upgrade to PHP8 but keep failing. I tried the following command and various more from the internet but nothing helped.

Below command was issued:

sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install php8.1

But the application keep on responding with such:

E: Unable to locate package php8.0 E: Couldn’t find any package by glob ‘php8.0’ E: Couldn’t find any package by regex ‘php8.0’

Below are my OS details (VPS):

NAME=“Ubuntu” VERSION=“16.04.7 LTS (Xenial Xerus)” ID=ubuntu ID_LIKE=debian PRETTY_NAME=“Ubuntu 16.04.7 LTS” VERSION_ID=“16.04” HOME_URL=“” SUPPORT_URL=“” BUG_REPORT_URL=“” VERSION_CODENAME=xenial UBUNTU_CODENAME=xenial

If I am required to upgrade my VPS, can someone guide me to do so? I am not used to develoment stuff and I have WordPress on my VPS. So how can I upgrade (if required) without losing all those stuff there?

Thank you in advance.

Regards, Jasveer

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Site Moderator
Site Moderator badge
February 28, 2023

Hello @jasveer

As with almost any upgrade between major releases of an operating system, this process carries an inherent risk of failure, data loss, or broken software configuration. Comprehensive backups and extensive testing are strongly advised.

To avoid these problems, we recommend migrating to a fresh Ubuntu 22.04 server rather than upgrading in-place. You may still need to review differences in software configuration when upgrading, but the core system will likely have greater stability. You can follow our series on how to migrate to a new Linux server to learn how to migrate between servers.


Site Moderator
Site Moderator badge
February 28, 2023

Hey @jasveer,

I can see you have an Ubuntu 16.04, that’s a really really really old one and it has been EOF a long time ago. You’ll need to upgrade it as soon as possible.

To do so, you can follow these steps:

remove unused packages and files

  1. sudo apt autoremove -y **&&** sudo apt autoclean -y

Upgrade commands

  1. sudo apt update -y **&&** sudo apt upgrade -y **&&** sudo apt dist-upgrade -y

Of course, before you run that, I’ll suggest creating a snapshot just to be safe in case something fails:

As for enabling PHP 8, usually the following works for updated systems :

  1. sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y

then enabling the repo

  1. sudo add-apt-repository ppa:ondrej/php

and lastly, instaling php 8:

  1. sudo apt install php8.1

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel