The message states different though. Any good reason why you are using Ondřej Surý’s PHP PPA package instead of simply using the official Ubuntu PHP repos on your server?
Maybe you have both PHP versions installed. If you don’t need both, make sure that you uninstall all 7.1 packages…
apt remove php7.1-*
if that doesn’t help, you could purge everything PHP related, including all the config files…
apt purge php*
…and then explicitly install a specific version and reconfigure it. Make sure that you install all required packages and you configure them properly. Be aware that there are speparate config files for each major version if you use Sury’s PPA. And if you purged all PHP packages all configuration changes have to be made again after you have reinstalled the pakages…
I use the PHP-FPM configuration from Carsten Rieger on my server. See the section Installation PHP 7.4 (alternativ php8.0-fpm) in the following tutorial: