我正尝试通过标准在 Fedora 17 EC2 实例上启动 Apache:
sudo systemctl start httpd.service
但我收到了错误“作业失败。有关详细信息,请参阅系统日志和‘systemctl status’。”
查看 /var/log/messages 后,我看到:
Oct 15 20:03:44 ip-10-72-15-170 dbus-daemon[383]: dbus[383]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.98" (uid=1000 pid=19645 comm="systemctl start httpd.service ") interface="org.freedesktop.systemd1.Manager" member="StartUnit" error name="(unset)" requested_reply="0" destination="org.freedesktop.systemd1" (uid=0 pid=1 comm="/usr/lib/systemd/systemd --log-level info --log-ta")
Oct 15 20:03:44 ip-10-72-15-170 dbus[383]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.98" (uid=1000 pid=19645 comm="systemctl start httpd.service ") interface="org.freedesktop.systemd1.Manager" member="StartUnit" error name="(unset)" requested_reply="0" destination="org.freedesktop.systemd1" (uid=0 pid=1 comm="/usr/lib/systemd/systemd --log-level info --log-ta")
Oct 15 20:03:50 ip-10-72-15-170 httpd[19650]: httpd: Could not open configuration file /etc/httpd/conf/httpd.conf: Permission denied
Oct 15 20:03:50 ip-10-72-15-170 TIFIER=systemd[1]: httpd.service: control process exited, code=exited status=1
Oct 15 20:03:50 ip-10-72-15-170 TIFIER=systemd[1]: Unit httpd.service entered failed state.
但是,我不明白为什么 Apache 不能读取它自己的配置文件,因为权限看起来是正确的:
[ec2-user@ec2-host ~]$ ls -lah /etc/httpd/conf/httpd.conf
-rw-rw-r--. 1 apache apache 7.3K Oct 15 19:14 /etc/httpd/conf/httpd.conf
这是怎么回事?我该如何修复此权限错误?
答案1
我刚刚httpd
在我的 Fedora 17 盒子上安装了它,看看可能存在什么问题。
因此,您遇到了两个问题:
- 这些文件的所有者是
root
,而不是apache
。 - 您可能正受到 SELinux 拒绝(
/var/log/audit/audit.log
尽管您没有发布任何内容)。
你的系统看起来应该是这样的:
drwxr-xr-x. root root system_u:object_r:httpd_config_t:s0 /etc/httpd
drwxr-xr-x. root root system_u:object_r:httpd_config_t:s0 /etc/httpd/conf
-rw-r--r--. root root system_u:object_r:httpd_config_t:s0 /etc/httpd/conf/httpd.conf