I'm trying to update my server to use PHP8.1 and I ended up disabling http/2 and also can't figure out how to re-enable it and actually get PHP8.1 to run.
The first steps I did were:
sudo a2dismod php7.4
sudo a2enmod php8.1
The second command had a conflict with mpm_event so I then ran:
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
After running "sudo a2enmod php8.1" again as well as "sudo systemctl restart apache2", it seemed okay.
However, whenever I run "php -v", it says that the CLI is "8.1" but using "phpinfo()" on the live site still returns "7.4.26".
I also ran these commands which all show that 8.1 is currently running:
sudo update-alternatives --config php
sudo update-alternatives --config phar
sudo update-alternatives --config phar.phar
sudo update-alternatives --config phpize
sudo update-alternatives --config php-config
After all of this, I noticed that my webpages stopped serving via http/2. Upon trying "sudo a2dismod mpm_prefork" so I can enable mpm_event again, it says that it can't disable mpm_prefork because there's a conflict with the PHP module. When I disable the PHP module, I can disable mpm_prefork and enable mpm_event but then I wouldn't have PHP anymore (I think? It's all so confusing...)
Edit: I tried disabling the PHP module and enabling mpm_event but it made the website not work anymore so I reverted those changes.
For clarity, when I try "sudo a2dismod mpm_prefork", I get this error:
ERROR: The following modules depend on mpm_prefork and need to be disabled first: php8.1
If it helps, phpinfo() says that I'm currently running:
PHP Version 7.4.26
Server API FPM/FastCGI
Configuration File (php.ini) Path /etc/php/7.4/fpm
Also, I now have PHP8.1 in my mods_enabled folder and I swear there were no PHP modules at all there before all this.
All in all, I'm very new to server management but I simply want to run PHP8.1 (fpm version?) while using http/2 but am running around in circles and I also took a step back with accidentally disabling http/2.
Edit: My question is basically three parts:
- Why did my site go offline after I disabled the PHP8.1 module? And, how do I prevent that from happening again?
- How do I safely re-enable mpm_event (so that http/2 will work again)? Keep in mind that it seems to only be an option when both PHP8.1 and mpm_prefork modules are disabled.
- How do I upgrade to PHP 8.1-fpm?
If an answer can provide steps for digging myself out of the hole that I dug myself into while also enabling PHP8.1-fpm then that would be awesome.
Oh, and just so it's clear; my current setup is:
- PHP8.1 and mpm_prefork modules are enabled (mpm_event is disabled)
- The live website is using PHP7.4-fpm without http/2
- The CLI version of PHP is PHP8.1
- I do not have PHP8.1-fpm installed