为什么 httpd 启动时符号链接配置文件不起作用?

为什么 httpd 启动时符号链接配置文件不起作用?

我正在努力设置一个新的反向代理来替换旧的。在测试时,我将虚拟主机指向测试服务器,但为了便于切换,我计划为每个虚拟主机配置设置 2 个版本,一个用于代理服务器的生产版本,一个用于测试版本,如下所示:

[root@rp01 /]# ls -l /etc/httpd/conf.d/vhosts/data.conf*
lrwxrwxrwx. 1 root root   14 Aug  2 15:12 /etc/httpd/conf.d/vhosts/data.conf -> data.conf.test
-rw-r--r--. 1 root root 1029 Aug  2 13:24 /etc/httpd/conf.d/vhosts/data.conf.prod
-rw-r--r--. 1 root root 1029 Aug  2 13:24 /etc/httpd/conf.d/vhosts/data.conf.test

但如果我这样做,httpd 将无法启动,并抛出没有权限在符号链接上:

[root@rp01 /]# systemctl start httpd
Job for httpd.service failed because the control process exited with error code.
See "systemctl status httpd.service" and "journalctl -xe" for details.
[root@rp01 /]# journalctl -xe
Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- Unit httpd.service has begun starting up.
Aug 02 15:20:13 rp01.******** httpd[1265]: httpd: Syntax error on line 356 of /etc/httpd/conf/httpd.conf: Syntax error on line 24 of /etc/httpd/conf.d/vhost.conf: Could not open configuration file /etc/httpd/conf.d/vhosts/data.conf: Permission denied
Aug 02 15:20:13 rp01.******** systemd[1]: httpd.service: Main process exited, code=exited, status=1/FAILURE
Aug 02 15:20:13 rp01.******** systemd[1]: httpd.service: Failed with result 'exit-code'.
Aug 02 15:20:13 rp01.******** systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- Unit httpd.service has failed.
-- 
-- The result is RESULT.

符号链接对于 Apache 用户来说可读,sudo -u apache cat /etc/httpd/conf.d/vhosts/data.conf运行良好。

SELinux?但是符号链接的上下文和它指向的文件是相同的。

有任何想法吗?

相关内容