2016-03-08 43 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

相关问题