检查 php 配置

检查 php 配置

我们的一个售票系统使用 php 作为应用程序,并且托管在 httpd 上。最近,有报告称 httpd 服务间歇性地出现故障。经过进一步调查,我发现没有安装 php 模块,使用的 mpm 是 mpm-event 而不是 mpm-prefork。此外,许多未使用的模块没有从 /usr/local/httpd/conf.modules.d 中的 00-base.conf 文件中注释掉。

我检查了 httpd 日志,发现这些错误:

AH00493: SIGUSR1 received.  Doing graceful restart

这些是显示间歇性 http 服务连接的完整日志(从 22 日到 29 日):

[Tue Sep 22 03:40:01.778015 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00493: SIGUSR1 received.  Doing graceful restart
[Tue Sep 22 03:40:01.978594 2020] [lbmethod_heartbeat:notice] [pid 15291:tid 140357203278016] AH02282: No slotmem from mod_heartmonitor
[Tue Sep 22 03:40:01.981317 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00489: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips   configured -- resuming normal operations
[Tue Sep 22 03:40:01.981358 2020] [core:notice] [pid 15291:tid 140357203278016] AH00094: Command line: '/opt/rh/httpd24/root/usr/sbin/httpd -D FOREGROUND'
[Wed Sep 23 03:48:02.613473 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00493: SIGUSR1 received.  Doing graceful restart
[Wed Sep 23 03:48:02.794093 2020] [lbmethod_heartbeat:notice] [pid 15291:tid 140357203278016] AH02282: No slotmem from mod_heartmonitor
[Wed Sep 23 03:48:02.797159 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00489: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips   configured -- resuming normal operations
[Wed Sep 23 03:48:02.797230 2020] [core:notice] [pid 15291:tid 140357203278016] AH00094: Command line: '/opt/rh/httpd24/root/usr/sbin/httpd -D FOREGROUND'
[Thu Sep 24 03:48:02.313840 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00493: SIGUSR1 received.  Doing graceful restart
[Thu Sep 24 03:48:02.470234 2020] [lbmethod_heartbeat:notice] [pid 15291:tid 140357203278016] AH02282: No slotmem from mod_heartmonitor
[Thu Sep 24 03:48:02.472765 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00489: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips   configured -- resuming normal operations
[Thu Sep 24 03:48:02.472829 2020] [core:notice] [pid 15291:tid 140357203278016] AH00094: Command line: '/opt/rh/httpd24/root/usr/sbin/httpd -D FOREGROUND'
[Fri Sep 25 03:44:02.157914 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00493: SIGUSR1 received.  Doing graceful restart
[Fri Sep 25 03:44:02.316100 2020] [lbmethod_heartbeat:notice] [pid 15291:tid 140357203278016] AH02282: No slotmem from mod_heartmonitor
[Fri Sep 25 03:44:02.319089 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00489: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips   configured -- resuming normal operations
[Fri Sep 25 03:44:02.319149 2020] [core:notice] [pid 15291:tid 140357203278016] AH00094: Command line: '/opt/rh/httpd24/root/usr/sbin/httpd -D FOREGROUND'
[Sat Sep 26 03:37:02.703473 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00493: SIGUSR1 received.  Doing graceful restart
[Sat Sep 26 03:37:02.854782 2020] [lbmethod_heartbeat:notice] [pid 15291:tid 140357203278016] AH02282: No slotmem from mod_heartmonitor
[Sat Sep 26 03:37:02.857291 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00489: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips   configured -- resuming normal operations
[Sat Sep 26 03:37:02.857434 2020] [core:notice] [pid 15291:tid 140357203278016] AH00094: Command line: '/opt/rh/httpd24/root/usr/sbin/httpd -D FOREGROUND'
[Sun Sep 27 03:07:02.134428 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00493: SIGUSR1 received.  Doing graceful restart
[Sun Sep 27 03:07:02.293453 2020] [lbmethod_heartbeat:notice] [pid 15291:tid 140357203278016] AH02282: No slotmem from mod_heartmonitor
[Sun Sep 27 03:07:02.295940 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00489: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips   configured -- resuming normal operations
[Sun Sep 27 03:07:02.295972 2020] [core:notice] [pid 15291:tid 140357203278016] AH00094: Command line: '/opt/rh/httpd24/root/usr/sbin/httpd -D FOREGROUND'
[Mon Sep 28 03:40:02.502201 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00493: SIGUSR1 received.  Doing graceful restart
[Mon Sep 28 03:40:02.655018 2020] [lbmethod_heartbeat:notice] [pid 15291:tid 140357203278016] AH02282: No slotmem from mod_heartmonitor
[Mon Sep 28 03:40:02.657714 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00489: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips   configured -- resuming normal operations
[Mon Sep 28 03:40:02.657785 2020] [core:notice] [pid 15291:tid 140357203278016] AH00094: Command line: '/opt/rh/httpd24/root/usr/sbin/httpd -D FOREGROUND'
[Tue Sep 29 03:16:02.338908 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00493: SIGUSR1 received.  Doing graceful restart
[Tue Sep 29 03:16:02.483232 2020] [lbmethod_heartbeat:notice] [pid 15291:tid 140357203278016] AH02282: No slotmem from mod_heartmonitor
[Tue Sep 29 03:16:02.485872 2020] [mpm_event:notice] [pid 15291:tid 140357203278016] AH00489: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips   configured -- resuming normal operations
[Tue Sep 29 03:16:02.485944 2020] [core:notice] [pid 15291:tid 140357203278016] AH00094: Command line: '/opt/rh/httpd24/root/usr/sbin/httpd -D FOREGROUND'

通过谷歌搜索这个错误,我发现给出的原因是 php 是一个非线程安全的软件,并且你不会将 worker(或其他线程 MPM)与非线程安全的软件一起使用。

我认为当前配置不正确,因此我编辑了 httpd.conf 以添加以下行:

<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

# Load php handler
AddHandler php5-script .php
AddType text/html .php

我还安装了 rh-php56-php 和 rh-php56,之前没有安装过。之前只安装了 rh-php56-php-fpm。所以现在我可以在各自的目录中看到 php 模块文件和 conf 文件。然后我在 httpd 中启用了 mpm-prefork 并禁用了 mpm-event。我还从 00-base.conf 中禁用了所有不需要的模块。重新启动 httpd 后,我可以看到 php 模块现已启用。

但是,我不确定这是否是解决此问题的正确解决方案。

我还检查了安装的 php 没有启用线程安全:

[root@its aigini]# /opt/rh/rh-php56/root/usr/bin/php -i | grep Thread
Thread Safety => disabled
[root@its aigini]#

我如何启用线程安全,这确实能解决问题吗?

根据下面的链接,我使用的步骤是一种线程安全的方法,但我仍然不确定:

[https://www.geeksforgeeks.org/what-is-thread-safe-or-non-thread-safe-in-php/][1]

如何解决间歇性的 http 服务问题?

相关内容