Persistent PHP-FPM Failure Issue on Rocky Linux and AlmaLinux

System Overview

  • Operating System: Rocky Linux 9 (also tested on AlmaLinux)
  • Webmin Version: 2.202
  • Virtualmin Version: 7.20.2
  • Web Server: Apache 2.4.62
  • PHP Configuration: Multiple PHP versions installed via PHP-FPM (default and custom versions).

Issue Description

For over a year, I have been experiencing random PHP failures on my server, which manifest as 503 Service Unavailable errors. Here’s a summary of the problem:

  1. Timing: Failures typically occurred every Sunday or Monday, irrespective of usage patterns.
  2. Workaround: Restarting the affected PHP-FPM version or the server temporarily resolves the issue.
  3. Scope: Only the manually installed PHP-FPM versions fail. The default system-installed PHP version works without any issues.
  4. Reproduction: The issue recurs when:
  • A new virtual server is created.
  • Custom PHP versions are installed.

Despite multiple attempts at resolving this, the root cause remains elusive.


Steps Taken

I have extensively investigated and attempted fixes based on various suggestions:

  1. Log Rotation Hypothesis:
  • It was suggested that log rotation might be causing PHP to stop responding.
  • Adjustments were made, but the issue persisted.
  1. Backup Scheduling Hypothesis:
  • Suspected conflicts with scheduled backups were addressed by disabling backup jobs.
  • This had no impact on the problem.
  1. Reinstallations and Distribution Testing:
  • Reinstalled the OS (both Rocky Linux and AlmaLinux).
  • Restored server backups.
  • Issues persisted on both distributions.
  1. PHP-FPM Specifics:
  • Default system PHP version (e.g., 8.0) runs without issues.
  • Manually installed versions (e.g., 7.4, 8.1) fail consistently under the same conditions.
  1. Switching to Debian:
  • Migrated to Debian-based distributions as a last resort.
  • The problem does not occur on Debian, suggesting the issue may be tied to Red Hat-based distributions or their PHP implementation.

Key Observations

  • The issue appears to affect Rocky Linux and AlmaLinux identically, potentially pointing to a shared upstream cause in Red Hat-based systems.
  • Custom-installed PHP versions consistently fail under similar conditions, while the default PHP version works reliably.
  • Creating a new virtual server or other resource-intensive operations seem to exacerbate the problem.

References

I have shared my experiences on the Virtualmin forums, where several others have encountered similar issues. Relevant discussions:


Conclusion

If you’re encountering similar issues on a Red Hat-based server, consider the following:

  • Check if the default PHP version works reliably.
  • Investigate potential conflicts with custom PHP installations or configurations.
  • If all else fails, consider switching to a Debian-based distribution, where these issues do not appear to occur.

I hope this summary helps someone facing similar challenges.

1 Like

This is from Debian 11. You have anything different?

root@main:/etc/cron.weekly# ls -lath
total 24K
drwxr-xr-x 133 root root  12K Dec  6 10:21 ..
drwxr-xr-x   2 root root 4.0K Feb  6  2023 .
-rwxr-xr-x   1 root root  813 Feb 10  2019 man-db
-rw-r--r--   1 root root  102 May  3  2015 .placeholder

And an obvious question. Is there some PHP software running maintenance once a week? I’d think most maintained software offers an upgrade path to 8 by now.

I dont have this issue with Debian only with Rocky or Alma. Everything is working fine on Debian 12 for me.

I never checked The cron I dont have anything custom there anyways and even when I reinstall alma or rocky it still happens and I dont backup cron

Software I do run on the server is mostly WordPress sites and nothing else really

Then why is php7 on the server? A reluctance to upgrade from old versions of WP? Believe me, I know the pain of failed upgrades. I’ve walked out to way too many sunrises. :wink: But, that said, you seem to be chasing a problem you should be trying to eliminate by moving away from anyhow. Ultimately the fix for php7 problems is php8.

Your main problem here is what I see on a site I help moderate. There it is a little easier to say ‘upgrade to the latest version because there has been many bug fixes’ than it is with php7. Few take an interest in trying to solve a problem with old software.

I’d be very surprised if something is broken about Red Hat-based distros. It’s (Rocky, specifically) what I use for everything (including Virtualmin.com), and we haven’t seen similar issues.

I’m glad you got it sorted, but I wouldn’t want to encourage folks to do dramatic things like a complete OS switch without good reason. Seems like there has to be an explanation for what was going wrong on your system. But, it’s certainly true that third-party packages are always less well-tested than the distribution standard packages. I recommend using the OS standard packages when possible.

I see I missed the 8.1 there. oops…

@crazyeyes198,

As you say the issue affects “custom” versions of PHP-FPM which are obviously distributed from a third-party repo. Perhaps these concerns should be directed to them for debugging, as if this is a bug, they’d be ones fixing it.

*** There is a reason why we “caution” the use of “third-party” repos and their software. They are not tested nor directly supported by the distro (ex. RedHat, Alma, Fedora, Debian, Ubuntu, etc). ***

Interesting read. I have two servers that used to run on CENTOS 7 but due its EOL had to change to AlmaLinux 8. With CENTOS 7: never had an issue but on both AlmaLinux instances I have near identical issues, very clearly related to PHP-FPM (running PHP8.3).

I’m not sure what to do yet. Don’t want to switch to Debian if I can help it.

I have been seeing similar issues, but only when mutliple versions of PHP are installed. I use the Remi Collet repo, which is has always been very reliable (especially as he is the maintainer of the Red Hat PHP releases).

One thing I have observed is that Virtualmin does not detect the PHP-FPM service as being ‘down’.

I’ve always used centos, moved to Rocky 9 (basically the same as Almalinux) and never had a issue, like Joe said.

Did you happen to see an error like this in your PHP-FPM error log?

[Mon Dec 09 10:46:07.671423 2024] [proxy:error] [pid 1042348:tid 1042394] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php-fpm/17295204724994.sock (127.0.0.1:8000) failed

1 Like

Nope, but I don’t run any (reverse) proxy.

The question is aimed at the OP.

If you use socket based PHP-FPM, I expect you will be proxying as that is how it is set up by Virtualmin.

2 Likes

I am no expert in this situation. Only thing i do know is using the default apache install and used the documentation to add the versions of PHP. But if i can remember right there was menstions of a socket file that is not found when i go to that file using winscp the file is there 0B in size when i double click on it to open it gives me a simular error message that the file is not found yet its there and i was as root. And all of them are in one folder does not matter what version it was.

Sorry i missed the log example you sent. That is exactly what i am getting

Thanks for confirming @crazyeyes198, it’s clearly got several ‘triggers’ reading through the other posts.

It’s an odd issue and I just encountered it again. This time it was due to very high load on the web server.

On this server we have 2 versions of PHP:

$ dnf repoquery --info --installed php*
....
Name         : php-fpm
Version      : 8.0.30
Release      : 1.el9_2
Architecture : x86_64
Size         : 8.2 M
Source       : php-8.0.30-1.el9_2.src.rpm
Repository   : @System
From repo    : rhel-9-for-x86_64-appstream-rpms

and

Name         : php83-php-fpm
Version      : 8.3.14
Release      : 1.el9.remi
Architecture : x86_64
Size         : 8.2 M
Source       : php83-php-8.3.14-1.el9.remi.src.rpm
Repository   : @System
From repo    : remi-safe

Apache returned a 503 error for the sites running PHP 8.3 and I could see the socket errors as above, however when I checked the status using php83-php-fpm everything was ‘apparently’ operating as expected.

systemctl status php83-php-fpm
● php83-php-fpm.service - The PHP FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php83-php-fpm.service; enabled; preset: disabled)
     Active: active (running)

The PHP 8.0 sites were not affected and php-fpm (the PHP 8.0 FPM process) did not need to be restarted.

I use 8.3 from remi on alma 9.5.

I rarely get crashes.

The last time it was related to nextcloud and the process management.

there is a tool to help you find good settings for your system:

PHP-FPM Process Caluculator

I’ve noticed that if I manually install a PHP version—like PHP 7.4—and it fails under heavy load for example, all the other manually installed PHP versions seem to fail too. Is that normal?

It would depend on why they have failed.

PHP-FPM services can be stopped by Out of Memory Killer (OOM Killer) - you can see if it has been by looking in your dmesg logs.

PHP-FPM processes could be used up, resulting in queues, where your CPU will be maxed out whilst it is trying to run the PHP scripts.

Or it could be the case where the services are still running but the requests stop being served (which is what we are looking at here).

1 Like