Apache不会停止/正常启动

CentOs 6 64bit运行apache 2.2.15-29.el6.centos。 当我尝试停止/启动或重新启动httpd时,出现错误,说明它失败了。 错误日志的尾部在下面。 我还注意到,即使在主要的conf文件中configuration了httpd.pid文件,它也不会被创build。

如果我将selinux设置为宽容,那么它工作得很好。 我不想在禁用selinux的情况下运行它。 如果我删除SSL_Mutex文件,它将启动。

HTTPD运行良好,直到我试图添加sslconfiguration。 我将ssl.conf文件从工作服务器复制到conf.d文件夹中。 我也复制了一个sslcert文件夹到conf文件夹。 它包含证书,密钥,csr和密码文件。 我认为这个问题与sslcert文件夹的selinux上下文有关,但我不确定如何解决这个问题。

执行restorecon -R sslcert之后,下面是sslcert文件夹的安全上下文
ls -Z

 -rw-r--r--. root root system_u:object_r:httpd_config_t:s0 httpd.conf -rw-r--r--. root root system_u:object_r:httpd_config_t:s0 magic **drwxr-xr-x. root root system_u:object_r:httpd_config_t:s0 sslcert** 

tail -f /var/log/httpd/error_log

 [Thu Oct 17 13:33:19 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Thu Oct 17 13:33:20 2013] [notice] Digest: generating secret for digest authentication ... [Thu Oct 17 13:33:20 2013] [notice] Digest: done [Thu Oct 17 13:33:20 2013] [warn] pid file /etc/httpd/logs/ssl.pid overwritten -- Unclean shutdown of previous Apache run? [Thu Oct 17 13:33:20 2013] [notice] Apache/2.2.15 (Unix) DAV/2 mod_ssl/2.2.15 OpenSSL/1.0.0-fips configured -- resuming normal operations [Thu Oct 17 21:04:48 2013] [notice] caught SIGTERM, shutting down [Thu Oct 17 21:06:42 2013] [notice] **SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0** [Thu Oct 17 21:06:42 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Thu Oct 17 21:06:42 2013] [error] (17)File exists: Cannot create SSLMutex with file `/etc/httpd/logs/ssl_mutex' 

我也看到了信号量可能出现的问题。 下面是当前信号量的输出,而apache目前没有运行。

ipcs -s

 ------ Semaphore Arrays -------- key semid owner perms nsems 0x00000000 0 root 600 1 0x00000000 65537 root 600 1 

最后selinux报告下面的错误。

 `sealert -a /var/log/audit/audit.log` 0% donetype=AVC msg=audit(1382034755.118:420400): avc: denied { write } for pid=3393 comm="httpd" name="ssl_mutex" dev=dm-0 ino=9513484 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:httpd_log_t:s0 tclass=file **** Invalid AVC allowed in current policy *** 100% doneERROR: failed to read complete file, 1044649 bytes read out of total 1043317 bytes (/var/log/audit/audit.log) found 1 alerts in /var/log/audit/audit.log -------------------------------------------------------------------------------- SELinux is preventing /usr/sbin/httpd from remove_name access on the directory ssl_mutex. 

之前也有类似的问题:

http://www.redhat.com/archives/fedora-selinux-list/2004-December/msg00067.html

检查ssl mutexconfiguration是否与默认的ssl.conf相同。

希望能帮助到你。

如果我将selinux设置为宽容,那么它工作得很好。 我不想在禁用selinux的情况下运行它。 如果我删除SSL_Mutex文件,它将启动。

将“rm -fv / path / to / apache / ssl_mutex_file”添加到你的httpd初始化脚本中?

[Thu Oct 17 21:06:42 2013] [error](17)文件存在:无法使用/ etc / httpd / logs / ssl_mutex文件创buildSSLMutex

有点hackish,但应该工作。 我通常禁用非共享服务器上的selinux。