我认为所有这些答案并没有真正回答问题。根级别可以通过运行命令来确定httpd -V。这将向您显示在编译时使用Apache守护程序构建哪些选项。这是控制在哪里httpd确定在何处查找其配置的内容。文件和.so模块默认情况下。
例如:
% httpd -V
Server version: Apache/2.2.17 (Unix)
Server built: Dec 17 2010 11:58:24
Server's Module Magic Number: 20051115:25
Server loaded: APR 1.3.12, APR-Util 1.3.9
Compiled using: APR 1.3.12, APR-Util 1.3.9
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-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"
该输出中的关键行是HTTPD_ROOT。在我的情况下,这定义了Apache的ROOT目录从哪里开始/etc/httpd寻找配置。文件和模块。
注意:这与ROOT是不同的DocumentRoot。这ROOT特定于httpd守护程序的编译方式,DocumentRoot用于指定httpd守护程序应从何处开始查找实际的Web内容(.html文件等)。
对于我的httpd.conf文件,我具有以下加载行:
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
鉴于此,模块的完整路径将是,例如:
/etc/httpd/modules/mod_auth_basic.so
这来自CentOS 5.x系统,但该技术仍然适用。
顺便说一句,这可能会引起一些混乱,因为在CentOS的情况下,文件实际上是在这里组织的:
% ls /usr/lib/httpd/modules/
libphp5.so mod_authnz_ldap.so mod_dav_fs.so mod_headers.so mod_perl.so mod_speling.so
...然后可httpd通过以下路径访问Apache守护程序:
% ls -l /etc/httpd/
total 12
drwxr-xr-x 2 root root 4096 Apr 26 2011 conf
drwxr-xr-x 3 root root 4096 Apr 26 2011 conf.d
-rw-r--r-- 1 root root 18 Feb 24 2009 htpasswd
lrwxrwxrwx 1 root root 19 Apr 26 2011 logs -> ../../var/log/httpd
lrwxrwxrwx 1 root root 27 Apr 26 2011 modules -> ../../usr/lib/httpd/modules
lrwxrwxrwx 1 root root 13 Apr 26 2011 run -> ../../var/run
该modules链接连接/etc/httpd- > /usr/lib/httpd/modules。