libphp-7.1.so
is either missing on your system, or in a place not configured in a way that Apache can find it. Likely it was removed during an upgrade of something but hard to tell.
You're finding out PHP is a mess to maintain on a Linux server. Especially on something like Ubuntu LTS (which may or may not be your distro, this is just my perspective) where you get the stability of LTS, but are then caught in a predicament which forces you to stay months to years behind new releases of other software which depend on newer functionality of "package X" to work correctly. Below is how I deal with it on Ubuntu. If you run Redhat, Slack, SuSE or Yggdrasil Linux, this won't be much help.
You can't just install a newer version of PHP without, at some point, running into dependency issues with the OS software. Sometimes these dependencies can run up against MySQL/MariaDB functionality which end can be a super tangled red pill type problem. As one person commented above, sometimes the version of PHP bundled with the standard OS is so far out of date it's unreasonable to use (which is definitely the case with anything less than PHP 8.0, and certainly sketchy with 7.4, as of 3/29/22). Also confusing for new admins because "why would your OS have software available that is so outdated?", right? Ubuntu apparently does backport security issues to LTS releases, but it takes a fair amount of digging to verify a given CVE is actually patched in the LTS packages. Sometimes a fix will be available and already implemented in the tarball/git repo of a given package, but the patch/backport is still waiting on a Ubuntu maintainer to actually roll it into the deb package so you can install it. Going out-of-band and installing software without a repo is treacherous from a security perspective because then you are relying on a manual process to remember to upgrade that OOB package and it never really works out. admins leave, people forget.
Luckly, there's this Debian maintainer Ondřej Surý (more like a wizard, really) from the Czech Repuplic who took it upon himself to put out a repo which includes all the underpinnings for upgrading PHP on Debian/Ubuntu system. You can configure this wonderous repo and upgrade PHP and still have it maintainable. As a bonus, you can upgrade NginX and Apache through his repo as well since some of the newer PHP functionality requires changes to those packages. You can probably find some better instructions at one of the links above, but there are a handful of sites which can walk you through it as well.along with any needed Nginx or Apache stack changes.
One word of caution, before installing the Ondřej Surý repo, get a listing of all the PHP/NginX/Apache packages currently installed (eg: dpkg -l | egrep -i '(apache|nginx|php)'
(or some similar incantation of apt
aptitude
apt-get
). The names of these packages DO change sometimes, and the dependencies sometimes bring in a mix of versions of the PHP packages. For instance, there was something that happened with the mbstring package a couple PHP versions ago. It required some manual intervention
Of course, all of this can sometimes be avoided with an OS upgrade (eg: "Crazy Camel" -> "Damaged Dingo") but even then, the latest LTS release may be missing bleeding edge functions that some 3rd party stack needs and you're still in the same boat.
Either way, good luck and don't forget to snapshot your VM before doing anything!