SELinux一直阻止我的Apache实例

我正在使用CentOS 7,并在那里使用systemd结构设置了一个重复的Apache实例。

如果我使用setenforce 0,我可以同时运行Apaches。但是,当我setenforce 1时,新的Apache将无法启动。

我尽我所能去查看所有创build的文件,并使用“ls -Z”复制了SELinuxtypes,然后chcon与httpd相同。

我得到的失败消息是:

[Thu Jun 23 23:51:24.123185 2016] [core:notice] [pid 24944] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0 [Thu Jun 23 23:51:24.124434 2016] [suexec:notice] [pid 24944] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Thu Jun 23 23:51:24.146830 2016] [auth_digest:notice] [pid 24944] AH01757: generating secret for digest authentication ... [Thu Jun 23 23:51:24.147901 2016] [lbmethod_heartbeat:notice] [pid 24944] AH02282: No slotmem from mod_heartmonitor [Thu Jun 23 23:51:24.147983 2016] [core:error] [pid 24944] (13)Permission denied: AH00099: could not create /etc/httpd-bobby/httpd-bobby.pid [Thu Jun 23 23:51:24.148000 2016] [core:error] [pid 24944] AH00100: httpd-bobby: could not log pid to file /etc/httpd-bobby/httpd-bobby.pid 

但位置有httpd上下文:

 [root~]# ls -Z /etc | grep httpd drwxr-xr-x. root root system_u:object_r:httpd_config_t:s0 httpd drwxr-xr-x. root root unconfined_u:object_r:httpd_config_t:s0 httpd-bobby 

我知道这是SELinux,因为它与setenforce 0.一起工作。我做错了什么?

有多个httpd上下文,这不是正确的。

pid文件所在的目录应该具有上下文httpd_var_run_t

我build议不要把它放在/ etc中,并在/ var / run中创build一个。

例如为/ var / run / httpd-bobby永久设置正确的上下文:

semanage fcontext -a -t httpd_var_run_t "/var/run/httpd-bobby(/.*)?" && restorecon /var/run/httpd-bobby