http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:

记一次http启动失败

环境:centos7.4 

原装环境:zabbix-server3.4(10051);zabbix-agent(10050);mariadb10.0(3306);httpd(Apache/2.4.6)(80,443)

新增环境:nginx-1.11.7(8081,8032,8033);php-fpm-5.3.28(9000)

[root@localhost conf.d]# mysql -V

mysql Ver 15.1 Distrib 10.0.32-MariaDB, for Linux (x86_64) using readline 5.1

[root@localhost conf.d]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Jun 27 2018 13:48:59

[root@localhost conf.d]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.11.7

[root@localhost conf.d]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.11.7
[root@localhost conf.d]# /usr/local/php/sbin/php-fpm -v
PHP 5.3.28 (fpm-fcgi) (built: Sep 13 2018 17:36:18)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies

早上新增环境后,8032,8033端口对应的web服务都能正常打开,但下午,想检查一下zabbix-server界面,发现打不开。

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第1张图片

期初,我以为是nginx和apache环境冲突,但其实两者都可以共存。但此时,发现httpd服务端口已经停用,当试图重启httpd服务时,报错。

[root@localhost conf.d]# systemctl restart httpd.service

Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

查看报错内容

[root@localhost conf.d]# systemctl status httpd.service -l

● httpd.service - The Apache HTTP Server

   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)

   Active: failed (Result: exit-code) since 六 2018-09-15 12:44:35 CST; 5min ago

     Docs: man:httpd(8)

           man:apachectl(8)

  Process: 20949 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)

  Process: 20947 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)

 Main PID: 20947 (code=exited, status=1/FAILURE)

9月 15 12:44:35 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...

9月 15 12:44:35 localhost.localdomain httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:

9月 15 12:44:35 localhost.localdomain httpd[20947]: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration

9月 15 12:44:35 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE

9月 15 12:44:35 localhost.localdomain kill[20949]: kill: cannot find process ""

9月 15 12:44:35 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1

9月 15 12:44:35 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.

9月 15 12:44:35 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.

9月 15 12:44:35 localhost.localdomain systemd[1]: httpd.service failed.

提示:/etc/httpd/conf.d/php.conf文件31行有语法错误

好吧,检查。貌似因为这个语法错误导致之后的“php_value”模块加载不出来。既然加载不出来,那么就尝试着注释掉它。

重启服务成功检查端口,端口存活

检查zabbix界面

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第2张图片

看来是失败了。

在zabbix.conf中继续注释php_value所指示的块

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第3张图片

重启服务,过滤端口,成功

检查web界面

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第4张图片

依旧错误

此时怀疑是php-fpm环境与原装php环境冲突,毕竟zabbix3.0以上版本对php环境的最低要求是php5.4,而新装的php-fpm版本是5.3,所以这是我最怀疑的。而通过php -v查询默认的php版本

[root@localhost conf.d]# php -v

Zend Guard Loader requires Zend Engine API version 220090626.

The Zend Engine API version 220100525 which is installed, is newer.

Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Guard Loader.

PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01)

Copyright (c) 1997-2013 The PHP Group

Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

默认版本也确实是php 5.4,所以这个原因排除。

仔细上网百度,发现国内各网站都没有针对这个问题作出详细解释。而无意间发现一个针对这个问题的讨论:https://serverfault.com/questions/515417/error-start-apache-php-value

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第5张图片

可以看到,问题几乎一模一样,可惭愧的是,人家5年前搞的东西,错误至今还在犯。

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第6张图片

按照他所提示的,将mod_php添加至httpd.conf。首先将注释掉的php_value还原

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第7张图片

在httpd.conf最后添加“LoadModule php5_module ../modules/libphp5.so”

重启httpd,重启成功,端口都在

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第8张图片

检查web界面

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第9张图片

错误。继续往下走,四年后的回答。。

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第10张图片

貌似同样的配置是在不同的文件中。他写到由于错误的配置导致php_value命令无效,即不可调用。

首先,找到/etc/httpd/conf.modules.d/10-php.conf文件,检查,正确

再找到/etc/httpd/conf.modules.d/00-mpm.conf文件,检查

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第11张图片

很直,因只有preforkmpm才可以在linux上运行,而个配置文件里指定的是mpm_worker,将其注,是上面的mpm_prefork生效

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第12张图片

保存退出,重启httpd服务,重启正常,端口正常

检查web界面

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第13张图片

正常。

问题得到解决,但意识到对php的配置文件作用了解很不够。要继续努力啊

普及一下:MPM( ( Multi-Processing Module )多路处理模块

检查,正常的应该如下,mem机制支持:/usr/sbin/httpd(即prefork模式)

http启动失败:httpd[20947]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:_第14张图片

所以,当php配置文件有语法错误时,也要想一想支持语法格式的模块是否正确。

你可能感兴趣的:(linux操作)