Now that the Piwigo server photographs were moved, and the Piwigo server disbanded, I went back to looking at my WordPress blog. Up till this point, I actually thought I was mostly done. Unfortunately, my problems were just beginning….
All I was going to do was log into my WordPress to start making some blog posts about all the “fun” I had upgrading Nextcloud from version 25 to 30. Unfortunately, I couldn’t log into my own self hosted WordPress blog. When I would go to the wp-admin page, it would say that I don’t have permission to be there! But, I found it easy enough to log in through the wp-login.php page. However, everything I did in the dashboard would give me errors. I couldn’t write a post, because it would error and say I couldn’t save it. I couldn’t enable/disable a plugin, because of errors. Then, strangely, it would “work” and catch up some of the things I did. The health page said that the REST services were giving it “unexpected results”.
I spent two days web researching these errors, turned on debugging, researched some more, implemented 20 different fixes that people claimed would work on the web, and all of them failed. It still wouldn’t work. That is when I finally found the WordPress PHP compatibility table [1] which shows that the only stable version of PHP for WordPress 6.6 is PHP 7.4! Now, it says that PHP 8.0, 8.1, and 8.2 are “compatible with exceptions” and PHP 8.3 is still in beta testing. According to the website, PHP 8.2 has all 8.1 and 8.0 exceptions, including:
Raised PHP 8.0 to compatible with exceptions.
- Exceptions:
- Named parameters. WordPress does not support named parameters.
- Filesystem
WP_Filesystem_FTPext
andWP_Filesystem_SSH2
when connect fails.Raised PHP 8.1 to compatible with exceptions.
All of these, though, seem to be issues, but shouldn’t cause my REST to fail, per my research. If you wonder what the WordPress REST is, here is a quote from the WordPress handbook [2]:
The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and receiving data as JSON (JavaScript Object Notation) objects. It is the foundation of the WordPress Block Editor, and can likewise enable your theme, plugin or custom application to present new, powerful interfaces for managing and publishing your site content.
All of the research I did lead me to believe that everything should still work with PHP 8.2, but to be sure, I switched back to PHP 7.4 just to double check. Sure enough, on PHP 7.4, my website not only worked, but the errors were all gone when I did actions in the dashboard, or tried to make posts. I could also log in through wp-admin instead of having to go directly to wp-login.php.
Well, that is frustrating.
I did this whole upgrade and got my Nextcloud updated to a version that requires a higher PHP version than is truly supported by my WordPress software! All of my research says it should work, but it doesn’t.
Of course, I couldn’t stay on PHP 7.4, because my Nextcloud needed PHP 8.x+. For a while, I actually experimented with other CMS options (content management system), most notably Grav [3]. However, no matter how hard I tried, I couldn’t get Grav to work right on my system either under PHP 8.2 or 8.3. In the end, I decided to enable individual websites hosted by my apache2 server to have different PHP versions so I could host my Nextcloud and my WordPress blog on the same apache2 server. Not the best answer, but it got me going again.
If, like me, you have never done this, a little bit of research showed that it is pretty simple to implement. First you install the multiple versions of PHPx.x-fpm that you want to use. In my case, they were already installed from my Nextcloud upgrade. Next, you install fcgid and enable the proxy to have different versions by running:
$ sudo apt install libapache2-mod-fcgid
$ sudo a2enmod actions fcgid alias proxy_fcgi
Then, you have to edit each of the enabled sites in your apache2 sites-available folder. You need to add a line like this:
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
This should go after the </Directory> and just before the Errorlog entries. You have to add this to each site you want to use a different version of PHP, so if you have a http and https version of a site, it needs to be in both configs. You can edit the php7.4-fpm to be any version of php that you have installed and enabled. By default, you usually only have one enabled, but you can start and enable others with:
$ sudo systemctl start php7.4-fpm
$ sudo systemctl enable php7.4-fpm
$ sudo systemctl start php8.2-fpm
$ sudo systemctl enable php8.2-fpm
... etc. for each version you want to have running ...
This is a pretty big band-aid for my problem. However, I still want to continue researching a way to use newer versions of PHP with WordPress, but in the meantime, this allows me to get up and running without ruining my Nextcloud server, which required PHP 8.x or newer.
That, or I may eventually switch to a flat file style blog, such as Grav or others.
Linux – keep it simple.
[1] https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/