'Although I upgraded to PHP 8, Wordpress recognizes only PHP 7.2 - WHY?

I have VPS with LAMP stack.

I tried to upgrade to PHP 8

When I run php -v

the version is 8.1

but Wordpress told me it is 7.2

I created a php file

<?php
phpinfo();
?>

it also tells me the following:

PHP Version 7.2.34-28+ubuntu18.04.1+deb.sury.org+1

According to some research I should disable 7.2 first so I tried

a2dismod php7.2

but I only get ERROR: Module php7.2 does not exist!

Can anyone help to switch to php 8?

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source