Permission denied: httpd: could not open error log file /etc/httpd/logs/error_log

MLSC picture MLSC · Mar 8, 2016 · Viewed 26.3k times · Source

When I want to restart the httpd searvice on centOS 6.7 I have the following error:

/etc/init.d/httpd restart
Stopping httpd:                                            [FAILED]
Starting httpd: (13)Permission denied: httpd: could not open error log file /etc/httpd/logs/error_log.
Unable to open logs
                                                           [FAILED]

This is error_log:

ls -Z /etc/httpd/logs/error_log
-rw-r--r--. root root unconfined_u:object_r:var_t:s0   /etc/httpd/logs/error_log

I disabled selinux also.

What is the problem?

Answer

Bart Friederichs picture Bart Friederichs · Mar 8, 2016

httpd runs probably as user apache or user httpd. Your log is owned and only writable by root. Change ownership of your logfile to make this work.

This should do the trick:

~# chown apache.apache /etc/httpd/logs/error_log