2
2

More than 5 years have passed since last update.

【Apache】困った、困ったApacheの再起動に失敗したらときと、ゾンビちゃんを一網打尽にする方法

Last updated at Posted at 2019-05-03

概要

みなさんはこんな経験ないですか?

# /etc/init.d/httpd restart
httpd を停止中: [失敗]
httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using xxx.xxx.xx.xx for ServerName
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[失敗]

apache再起動したいけど、できないざますー!!!

そんな時はこのコマンドを叩いてみましょう
httpdのプロセスが ざわついていませんか? ざわざわっ

$ ps auxw | grep httpd
user    24484  0.0  0.3 285604 13060 ?        S    Jan01   0:08 /usr/sbin/httpd
user    24485  0.0  0.3 285604 13048 ?        S    Jan01   0:08 /usr/sbin/httpd
user    24486  0.0  0.3 285604 13044 ?        S    Jan01   0:08 /usr/sbin/httpd

上記は、通常の状態ですが、起動時間がやたら長いのがいたり、ユーザーが?????とかよくわからん
プロセスがいたりして再起動に失敗している場合があります
怪しいプロセスがいた場合は下記コマンドを実行して、ゾンビちゃんを一網打尽にしましょう w

kill -9 `ps auxw | grep httpd | awk '{print $2}'`

解説

kill -9 はプロセスを強制終了します。
プロセスをキルするとか殺すとかいいますね。

ps auxw | grep httpd | awk '{print $2}'
こちらは httpdのプロセスの2要素目のリストを出力しています。
参考までにこのコマンドだけ実行すると↓のようになります

$ ps auxw | grep httpd | awk '{print $2}'
1633
9901
24484
24485
24486

結論

要はhttpdのプロセスを全部killしているだけです。

実行する際は、webを参照しているユーザもいるかもしれないので、
えいやー!!! ではなく、関係各所やタイミングを図りましょうw

それではよい Linux Apache ライフを!!

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2