Apache MPM混乱--需要澄清

Apache MPM混乱--需要澄清,apache,Apache,我在linux机器上工作,我没有编译和构建Apache。我不知道我在使用哪个Apache MPM(prefork或worker),因为在/usr/sbin/中似乎都有可执行文件。这是一个CentOS盒子: httpd httpd.worker 脚本/usr/sbin/apachectl中有以下行: # the path to your httpd binary, including options if necessary HTTPD='/usr/sbin/httpd' 但是,/usr/sb

我在linux机器上工作,我没有编译和构建Apache。我不知道我在使用哪个Apache MPM(prefork或worker),因为在/usr/sbin/中似乎都有可执行文件。这是一个CentOS盒子:

httpd
httpd.worker
脚本/usr/sbin/apachectl中有以下行:

# the path to your httpd binary, including options if necessary
HTTPD='/usr/sbin/httpd'
但是,/usr/sbin/apachectl在下面的文件中也显示了HTTPD配置,这使我相信它覆盖了HTTPD的上述选项,并将其指向HTTPD.worker:

$ cat /etc/sysconfig/httpd
# Configuration file for the httpd service.

#
# The default processing model (MPM) is the process-based
# 'prefork' model.  A thread-based model, 'worker', is also
# available, but does not work with some modules (such as PHP).
# The service must be stopped before changing this variable.
#
HTTPD=/usr/sbin/httpd.worker

#
# To pass additional options (for instance, -D definitions) to the
# httpd binary at startup, set OPTIONS here.
#
#OPTIONS=

#
# By default, the httpd process is started in the C locale; to 
# change the locale in which the server runs, the HTTPD_LANG
# variable can be set.
#
#HTTPD_LANG=C

#
# By default, the httpd process will create the file
# /var/run/httpd/httpd.pid in which it records its process
# identification number when it starts.  If an alternate location is
# specified in httpd.conf (via the PidFile directive), the new
# location needs to be reported in the PIDFILE.
#
#PIDFILE=/var/run/httpd/httpd.pid
ps -C httpd.worker -F
UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
root     13603     1  0 34690  4852   1 01:58 ?        00:00:00 /usr/sbin/httpd.worker
apache   13605 13603  0 34619  2352   1 01:58 ?        00:00:00 /usr/sbin/httpd.worker
apache   13606 13603  0 123554 7444   1 01:58 ?        00:00:00 /usr/sbin/httpd.worker
apache   13607 13603  0 240987 52604  0 01:58 ?        00:00:00 /usr/sbin/httpd.worker
apache   13609 13603  0 273755 52396  0 01:58 ?        00:00:00 /usr/sbin/httpd.worker
apache   13611 13603  0 290139 52128  0 01:58 ?        00:00:00 /usr/sbin/httpd.worker
我的结论是,我正在使用MPM worker。然而,为什么我会在/usr/sbin中有一个httpd可执行文件,它似乎被编译为MPM prefork?看看这些命令?也许吧

# httpd -l
compiled in modules:
core.c
prefork.c
http_core.c
mod_so.c

$ httpd -V
Server version: Apache/2.2.15 (Unix)
Server built:   Feb 13 2012 22:31:42
Server's Module Magic Number: 20051115:24
Server loaded:  APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture:   64-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="run/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.worker -l
Compiled in modules:
core.c
worker.c
http_core.c
mod_so.c

$ apachectl -l
Compiled in modules:
core.c
worker.c
http_core.c
mod_so.c
# apachectl -V
Server version: Apache/2.2.15 (Unix)
Server built:   Feb 13 2012 22:33:00
Server's Module Magic Number: 20051115:24
Server loaded:  APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture:   64-bit
Server MPM:     Worker
   threaded:     yes (fixed thread count)
   forked:     yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/worker"
-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_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
我相信我运行httpd.worker的最后一个原因是:

$ cat /etc/sysconfig/httpd
# Configuration file for the httpd service.

#
# The default processing model (MPM) is the process-based
# 'prefork' model.  A thread-based model, 'worker', is also
# available, but does not work with some modules (such as PHP).
# The service must be stopped before changing this variable.
#
HTTPD=/usr/sbin/httpd.worker

#
# To pass additional options (for instance, -D definitions) to the
# httpd binary at startup, set OPTIONS here.
#
#OPTIONS=

#
# By default, the httpd process is started in the C locale; to 
# change the locale in which the server runs, the HTTPD_LANG
# variable can be set.
#
#HTTPD_LANG=C

#
# By default, the httpd process will create the file
# /var/run/httpd/httpd.pid in which it records its process
# identification number when it starts.  If an alternate location is
# specified in httpd.conf (via the PidFile directive), the new
# location needs to be reported in the PIDFILE.
#
#PIDFILE=/var/run/httpd/httpd.pid
ps -C httpd.worker -F
UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
root     13603     1  0 34690  4852   1 01:58 ?        00:00:00 /usr/sbin/httpd.worker
apache   13605 13603  0 34619  2352   1 01:58 ?        00:00:00 /usr/sbin/httpd.worker
apache   13606 13603  0 123554 7444   1 01:58 ?        00:00:00 /usr/sbin/httpd.worker
apache   13607 13603  0 240987 52604  0 01:58 ?        00:00:00 /usr/sbin/httpd.worker
apache   13609 13603  0 273755 52396  0 01:58 ?        00:00:00 /usr/sbin/httpd.worker
apache   13611 13603  0 290139 52128  0 01:58 ?        00:00:00 /usr/sbin/httpd.worker

如果您在CentOS上,请打开/usr/sbin/apachectl以及您提到的以下几行

# the path to your httpd binary, including options if necessary 
HTTPD='/usr/sbin/httpd'
您将看到以下几行:

# Source /etc/sysconfig/httpd for $HTTPD setting, etc.
if [ -r /etc/sysconfig/httpd ]; then
   . /etc/sysconfig/httpd
fi
这就是apachectl获取和重写apachectl自己的HTTPD变量的方式


这也意味着您确实在使用worker mpm而不是prefork。

如果您在CentOS上,请打开/usr/sbin/apachectl,并在您提到的以下几行下面

# the path to your httpd binary, including options if necessary 
HTTPD='/usr/sbin/httpd'
您将看到以下几行:

# Source /etc/sysconfig/httpd for $HTTPD setting, etc.
if [ -r /etc/sysconfig/httpd ]; then
   . /etc/sysconfig/httpd
fi
这就是apachectl获取和重写apachectl自己的HTTPD变量的方式

这也意味着您确实在使用worker mpm而不是prefork