阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Ubuntu Server 14.04 下 service php-fpm restart 提示 restart: Unknown instance

121次阅读
没有评论

共计 2224 个字符,预计需要花费 6 分钟才能阅读完成。

在 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

似乎,进程没有停下来?

再试一次:

Ubuntu Server 14.04 下 service php-fpm restart 提示 restart: Unknown instance

确认这个出现了奇怪的 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,再重启,正常了。

更多 Ubuntu 相关信息见 Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2016-07/133682.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计2224字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中