2016-03-08 42 views
3

當我想要重新啓動在CentOS 6.7 httpd的searvice我有以下錯誤:權限被拒絕:的httpd:無法打開錯誤日誌文件/ etc/httpd的/日誌/ error_log中

/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] 

這是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 

我也禁用了selinux。

什麼問題?

回答

3

httpd可能以用戶apache或用戶httpd運行。您的日誌擁有且只能由root寫入。更改您的日誌文件的所有權以使其工作。

這應該做的伎倆:

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

也許你應該改變組forder到Apache的,它不建議有根作爲服務器上的東西所有者。反正阿帕奇應該改變的是他自己的HTTP開始後...

httpd Wiki

Before we start, we need to be aware that the Apache HTTP server (httpd) runs as a particular user and group.

On Linux as well as most other Unix-like systems, httpd is started as the "root" user; UID=root, GID=root. This is necessary because only this user can bind to port 80 and 443 (anything below 1024 in fact).

After http starts and binds to its ports (defined by the Listen statments in httpd.conf), it changes user to that specified in httpd.conf. Typically:

User: apache
Group: apache

Note that Debian based systems, including Ubuntu, use "www-data" instead.

作爲一個可能的解決方案,你應該自己添加到組阿帕奇

usermod -a -G apache (username) 

然後:

chgrp apache (folderPath) 
chmod g+rwxs (folderPath) 

無論如何這很奇怪......告訴我,如果這解決了您的問題,如果沒有,我會,只要你給我提供更多的信息:)

+0

這是CentOS的,所以我認爲我們沒有'www-data'。 – MLSC

+1

@MLSC然後更改Apache數據庫,如httpd wiki片段中所述 – Asur

-1

編輯它,只要運行它作爲超級用戶:

service httpd start 

Starting httpd: (13)Permission denied: httpd: could not open error log file /etc/httpd/logs/error_log.

Unable to open logs [FAILED]

sudo service httpd start 

Starting httpd: [ OK ]

+0

請不要,不要以root身份運行apache,這樣可以解決上述問題,但存在安全風險,並且會變得更糟 – chrisweb

相關問題