Apache 无法正常停止/启动

Apache 无法正常停止/启动

CentOs 6 64 位运行 apache 2.2.15-29.el6.centos。当我尝试停止/启动或重新启动 httpd 时,我收到一条错误消息,提示它已失败。错误日志的末尾如下。我还注意到,尽管在主配置文件中配置了 httpd.pid 文件,但并未创建该文件。

如果我将 selinux 设置为 permissive,它就可以正常工作。我不想在禁用 selinux 的情况下运行它。如果我删除 SSL_Mutex 文件,它就会启动。

在我尝试添加 ssl 配置之前,HTTPD 运行良好。我将 ssl.conf 文件从工作服务器复制到 conf.d 文件夹中。我还将 sslcert 文件夹复制到 conf 文件夹中。它包含证书、密钥、csr 和密码文件。我认为问题与复制的 sslcert 文件夹的 selinux 上下文有关,但我不确定,也不知道如何修复它。

以下是执行后 sslcert 文件夹的安全上下文restorecon -R 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.

答案1

之前也出现过类似的问题:

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

检查 ssl mutex 配置是否与默认 ssl.conf 中的配置相同。

希望能帮助到你。

答案2

如果我将 selinux 设置为 permissive,它就可以正常工作。我不想在禁用 selinux 的情况下运行它。如果我删除 SSL_Mutex 文件,它就会启动。

将“rm -fv /path/to/apache/ssl_mutex_file”添加到您的 httpd init 脚本?

[2013 年 10 月 17 日星期四 21:06:42] [错误] (17)文件存在:无法使用文件“/etc/httpd/logs/ssl_mutex”创建 SSLMutex

有点像黑客行为,但应该可以工作。我通常在非共享服务器上禁用 selinux。

相关内容