0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Apache】なんか再起動できなくなった時の対処

Posted at

はじめに

何回かApacheをrestartしていたら、急にエラーが起きることがありました。
原因がぱっと見のエラー文が同じなのに、原因と対処法が違ったのでまとめておきます。
サーバーはCentOS 7.4、Apacheのバージョンは2.4です。

現象

apachectl restartでサーバーを再起動しようとしたら、

Failed to start The Apache HTTP Server

で再起動できなくなりました。

パターン1

原因

kill: cannot find process ""

というメッセージがありました。

原因としては、すでに動いているプロセスがあるので再起動できていない状態になっています。

対策

80ポートで動いているプロセスを探して停止すると上手くいきました。

netstat -lnp | grep :80
kill <プロセス番号>

netstatで通信のポート・プロセス情報を表示して、80ポートで動いているプロセスを探します。
killコマンドで停止してから起動します。

パターン2

再起動を繰り返していた時に陥りました。

原因

セマフォを使い切っていたことが原因でした。

ipcs -s

でセマフォの使用状況を取得できます。
ownerがapacheのものがいっぱいあったら、このパターンだと思います。

対策

for i in `ipcs -s | awk '/apache/ {print $2}'`; do (ipcrm -s $i); done

ipcs -sでセマフォの使用状況を取得後、apacheがownerの行からIDを抜き出します。
それらをipcrm -s に渡して開放してあげます。

最後に

他のパターンに遭遇したらまた追記します。
間違いがあったらご指摘をお願いします。

参考

http://inaz2.hatenablog.com/entry/2013/04/16/222440
http://kanjuku-tomato.blogspot.com/2015/07/apache.html

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?