設定ファイルを見ないでhttpdのログの場所を知る方法
急なトラブル解析で、全く知らないサーバの解析をさせらることありますよね。
そんな時に役立つログの場所の見つけ方です。httpdとタイトルにあるけど、どんなMWでも使えます。
rootユーザにさせてもらう。
$su -
もしくは
$sudo su -
httpdのプロセスIDを特定する。
#ps -ef |grep httpd
root 2820 1 0 Dec14 ? 00:00:02 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
daemon 2825 2820 0 Dec14 ? 00:00:13 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
daemon 2826 2820 0 Dec14 ? 00:00:10 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
daemon 4362 2820 0 Dec14 ? 00:00:11 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
root 8661 8626 0 13:35 pts/0 00:00:00 grep --color=auto httpd
下のコマンド叩けば、httpdのプロセスが掴んでいるファイルディスクリプタが見え、そのプロセスが吐いているログの場所がわかります。
#ll /proc/2820/fd
total 0
dr-x------ 2 root root 0 Dec 15 13:21 ./
dr-xr-xr-x 9 root root 0 Dec 14 11:48 ../
lr-x------ 1 root root 64 Dec 15 13:23 0 -> /dev/null
l-wx------ 1 root root 64 Dec 15 13:23 1 -> /dev/null
l-wx------ 1 root root 64 Dec 15 13:23 2 -> /opt/bitnami/apache2/logs/error_log
lrwx------ 1 root root 64 Dec 15 13:23 3 -> socket:[10158]
l-wx------ 1 root root 64 Dec 15 13:23 4 -> pipe:[10184]
l-wx------ 1 root root 64 Dec 15 13:23 5 -> /opt/bitnami/apache2/logs/access_log
真実はドキュメントではなくサーバにあります。