Apacheの設定ファイル /etc/httpd/conf
にエラーログを吐き出す場所を指定する項目がありますが、下記のようにエラーログを作成して、試しにさ、くらVPSのCentOSでPHPのシンタックスエラーをしてみてもエラーログは /etc/httpd/logs
に吐き出されてしまいます。何が原因かアドバイスいただけますでしょうか。
ErrorLog "/var/log/php/error.log"
bash
1 2logs]# ls 3 4access_log access_log-20170605 error_log-201701229 error_log-20170605 index.html.1 5access_log-20170514 access_log-20170611 error_log-20170514 error_log-20170611 6access_log-20170522 error_log error_log-20170522 index.html
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。

回答4件
0
ベストアンサー
手元の環境で確認しました。
- CentOS7を新規インストール
- yum install -y httpd php
- /etc/httpd.confのerrolog出力を「/var/log/php/error.log」に変更
- mkdir /var/log/php ; chown apache:apache /var/log/php
- service httpd restart
で、/var/log/php/error.logに
[Sat Jun 17 15:04:28.112186 2017] [core:notice] [pid 9842] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0 [Sat Jun 17 15:04:28.112984 2017] [suexec:notice] [pid 9842] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Sat Jun 17 15:04:28.137451 2017] [auth_digest:notice] [pid 9842] AH01757: generating secret for digest authentication ... [Sat Jun 17 15:04:28.138304 2017] [lbmethod_heartbeat:notice] [pid 9842] AH02282: No slotmem from mod_heartmonitor [Sat Jun 17 15:04:28.154936 2017] [mpm_prefork:notice] [pid 9842] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations [Sat Jun 17 15:04:28.154962 2017] [core:notice] [pid 9842] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND' error.log (END)
と記録されたのを確認しました。
やはり繰り返しになりますが、conf.d/*.confを変更している可能性が高いですね。
grep -r "ErrorLog" /etc/httpd/ と実行してみて、
/etc/httpd/conf/httpd.conf:# ErrorLog: The location of the error log file. /etc/httpd/conf/httpd.conf:# If you do not specify an ErrorLog directive within a <VirtualHost> /etc/httpd/conf/httpd.conf:ErrorLog "/var/log/php/error.log"
以外の情報が表示されませんか?
投稿2017/06/17 06:21
総合スコア76
0
182c182 < ErrorLog "logs/error_log" --- > ErrorLog "/etc/httpd/logs"
ログを履こうとしているフォルダは、
/var/log/php/error.log
じゃなかったです?
上記の設定は、
/etc/httpd/ にlogs と言うファイルを出力しています。
(確か、所有者がrootなのでapatchユーザーは書き込めなかったと思います)
投稿2017/06/17 01:58
編集2017/06/17 02:01総合スコア76
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
0
VirtualHostの設定を行っているのではないでしょうか?
httpd.conf内に
ErrorLog "logs/error_log"
と書いていても、
IncludeOptional conf.d/*.conf
と、他設定を読み込んでいるのであれば、そちらの設定が上書きされます。
つまり、/etc/httpd/conf.d/vhost.confとかに
<VirtualHost *:80>
ServerAdmin root
DocumentRoot "/var/www/http"
ServerName www.example.com
ErrorLog "/var/log/php/error.log"
(中略)
と書けば、意図した場所にログファイルが出力されると思います。
投稿2017/06/14 12:40
総合スコア76
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。

0
以下のような対応でどうでしょうか。
mkdir /var/log/php touch /var/log/php/error.log chcon -t httpd_log_t /var/log/php/error.log chown apache. /var/log/php/error.log chmod 600 /var/log/php/error.log
以下も参考にどうぞ。
CentOS で PHP のエラーログが出力されない
投稿2017/06/14 10:27
総合スコア580
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/18 11:55