ubuntu php-fpm 重启,Ubuntu Server 14.04 下 service php-fpm restart 提示 restart: Unknown instance...

在 WordPress 里作出的修改在主题更新版本的时候全部会丢失所以一直没更新,今天想参考 官方文档 通过子主题的办法升级,但是一点更换主题就白屏以至于整个网站都挂掉了,curl -I 发现是http 500,检查 PHP 进程健在,nginx 健在,检查先前的步骤并无不妥于是开始查日志 /var/log/nginx/error.log 。

Shell

[error] 8114#0: *245 FastCGI sent in stderr: "PHP message: PHP Fatal error: Cannot redeclare get_gravatar_back() in /xxxxxxxx/functions.php on line 9" while reading response header from upstream, client: xx.xxx.xxx.xxx, server: www.starduster.me, request: "GET /2015/08/11/CentOS7-linux-pma-session-error/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.starduster.me", referrer: "http://www.starduster.me/"

似乎是我修改过的 functions.php 出了什么问题,于是想查看一下 PHP 的日志,

Shell

NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful

咦,为什么什么消息也没有?

然后一想这个日志是 php-fpm 进程的日志,检查程序运行错误应该在其他地方,于是检查 /etc/php5/fpm/pool.d/www.conf

发现 php_admin_value[error_log] = /var/log/php-fpm/www-error.log 这行被注释掉了,删掉注释,重启服务。

Shell

service php5-fpm restart

蹦出了个奇怪的错误:

Shell

stop: Unknown instance:

php5-fpm start/running, process 18302

似乎,进程没有停下来?

再试一次:

fd9a59a7a043cf5f619a6595b758f86b.png

确认这个出现了奇怪的 bug,于是放狗搜索。

从一个 stackoverflow 的问题得知这是一个已经确认的系统 bug( 官网链接 ) ,出现在 Ubuntu 低于15.04的各个版本上,这个问题时间是2013年,竟然现在还没有通过修改包来解决,最后一条评论( 2015-07-27)写到:

I have documented the workaround in the bug description. This bug presumably does not affect releases >= Vivid since it is related to upstart and Ubuntu runs systemd since Vivid.So marking Fix Released and creating a Trusty task in case someone can come up with a good fix for Trusty that can be SRU’d. Importance -> Medium as a workaround is available·····

status: Confirmed → Fix Released

importance: Undecided → Medium

意思就是说既然新版本不影响这 bug 就不重要了吗WTF?

完整的解决方案在 Github (全程使用 root 操作) :

这个 Github repo 的作者写到:

By default it never happens. Possibly after optimizing the www.conf file, somehow it activate this.

在默认环境下这个错误不会出现,错误可能是因为你修改了www.conf配置文件。

如果你不想保留现有的 PHP 环境相关配置,可以直接重装:

Shell

apt-get purge php5-fpm && apt-get install php5-fpm

如果你想对 php-fpm 配置进行修改,先编辑 /etc/init/php-fpm.conf

解除这行的注释: reload signal USR2

备份现有的 init.d 文件:

Shell

mv /etc/init.d/php5-fpm ~/php5-fpm.bak

从 Github 导入新的 init.d 文件:

Shell

curl -L https://raw.githubusercontent.com/AbhishekGhosh/Nginx-PHP5-FPM-Restart-Fix-on-Ubuntu/master/php5-fpm > /etc/init.d/php5-fpm

chmod +x /etc/init.d/php5-fpm

Github 原文说这时候重启服务即可,而我的情况是这时候问题依旧,尝试强杀进程:

Shell

pkill php5-fpm

再尝试使用 service 启动 php5-fpm ,再重启,正常了。

0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值