Php 权限被拒绝:httpd:无法打开错误日志文件/etc/httpd/logs/error\u log
当我想在centOS 6.7上重新启动httpd searvice时,出现以下错误:Php 权限被拒绝:httpd:无法打开错误日志文件/etc/httpd/logs/error\u log,php,apache,httpd.conf,selinux,Php,Apache,Httpd.conf,Selinux,当我想在centOS 6.7上重新启动httpd searvice时,出现以下错误: /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
/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]
这是错误日志:
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
问题是什么?
httpd
可能作为用户apache
或用户httpd
运行。您的日志由root用户拥有且只能写入。更改日志文件的所有权以使其生效
这应该可以做到:
~# chown apache:apache /etc/httpd/logs/error_log
可能您应该将forder的组更改为apache,不建议将root作为服务器的所有者。无论如何,apache应该在http启动后自己改变这一点
发件人:
在开始之前,我们需要知道ApacheHTTP服务器
(httpd)作为特定用户和组运行
在Linux以及大多数其他类似Unix的系统上,httpd的启动方式是
“根”用户;UID=root,GID=root。这是必要的,因为只有
该用户可以绑定到端口80和443(实际上是1024以下的任何端口)
http启动并绑定到其端口(由侦听器定义)后
在httpd.conf中,它将用户更改为中指定的用户
httpd.conf。通常:
用户:apache
组别:apache
请注意,基于Debian的系统,包括
Ubuntu,改用“www数据”
作为一种可能的解决方案,您应该将自己加入apache组
usermod -a -G apache (username)
然后:
不管怎样,这很奇怪。。。告诉我这是否解决了您的问题,如果没有,我将编辑它,只要您向我提供更多信息:)只需以超级用户身份运行它:
service httpd start
启动httpd:(13)权限被拒绝:httpd:无法打开错误日志文件/etc/httpd/logs/error\u log
无法打开日志[失败]
正在启动httpd:[确定]
这是centOs,所以我认为我们没有www-data
@MLSC,然后按照httpd wiki片段中提到的更改apache的www-data。请不要以root用户身份运行apache,这解决了所描述的问题,但存在安全风险,可能是worsechown:apache.apache:非法用户名
service httpd start
sudo service httpd start