通过 rc 脚本加载时,httpd 未加载 httpd.conf 文件

通过 rc 脚本加载时,httpd 未加载 httpd.conf 文件

二进制位于/usr/sbin/

当我跑步的时候strace -o httpdstart.txt /usr/bin/httpd -k start

它有以下几行来打开httpd.conf

stat("/etc/httpd/conf/httpd.conf", {st_mode=S_IFREG|0644, st_size=35894, ...}) = 0
open("/etc/httpd/conf/httpd.conf", O_RDONLY|O_CLOEXEC) = 3

因此,当通过以下方式手动加载时:

httpd -k start

或者

/usr/bin/httpd -k start

httpd使用 for 配置即可按预期加载/etc/httpd/conf/httpd.conf

我也跑了strace -o httpdstart.txt /etc/init.d/httpd -k start

我得到:

Usage: httpd {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}

所以用法表明我不能对 httpd rc 脚本使用任何选项。

于是我运行了strace -o httpdstart1.txt /etc/init.d/httpd start。它没有打开任何httpd.conf文件的痕迹。


init.d 中的 httpd rc 脚本包含:

apachectl=/usr/sbin/apachectl
httpd=${HTTPD-/usr/sbin/httpd}

即它指向正确的二进制文件。


httpd -V输出如下:

服务器版本:Apache/2.2.21 (Unix)
服务器构建:2011 年 9 月 13 日 13:46:54
服务器模块幻数:20051115:30
服务器加载:APR 1.4.5、APR-Util 1.3.10
编译使用:APR 1.4.5、APR-Util 1.3.12
架构:64 位
服务器 MPM:Prefork
线程:否
分叉:是(可变进程数)
服务器编译使用....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6(已启用 IPv4 映射地址)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"


当通过 rcscript 加载时,DocumentRoot 不会设置,并且

ErrorDocument 403 /error/noindex.html

发生(出现在welcome.conf中),并加载Fedora Test Page。如果我删除welcome.conf。我将得到一个Forbidden You don't have permission to access / on this server。这里出了什么问题?

答案1

在我看来,这是两个不同的 Apache。一个位于 /usr/垃圾桶/httpd 和 /usr/ 处的另一个系统/httpd. 尝试手动启动“sbin”并查看 httpd -V 的输出是否与通过 rc 脚本启动时的输出相同。

相关内容