Apache Prefork vs Worker MPM

后端 未结 7 2014
难免孤独
难免孤独 2020-12-07 08:07

Looking at the Apache config file, I see Prefork and Worker MPM defined. What is the difference and which one is Apache using?

相关标签:
7条回答
  • 2020-12-07 08:42

    Its easy to switch between prefork or worker mpm in Apache 2.4 on RHEL7

    Check MPM type by executing

    sudo httpd -V
    
    Server version: Apache/2.4.6 (Red Hat Enterprise Linux)
    Server built:   Jul 26 2017 04:45:44
    Server's Module Magic Number: 20120211:24
    Server loaded:  APR 1.4.8, APR-UTIL 1.5.2
    Compiled using: APR 1.4.8, APR-UTIL 1.5.2
    Architecture:   64-bit
    Server MPM:     prefork
      threaded:     no
        forked:     yes (variable process count)
    Server compiled with....
     -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=256
     -D HTTPD_ROOT="/etc/httpd"
     -D SUEXEC_BIN="/usr/sbin/suexec"
     -D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
     -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"
    

    Now to change MPM edit following file and uncomment required MPM

     /etc/httpd/conf.modules.d/00-mpm.conf 
    
    # Select the MPM module which should be used by uncommenting exactly
    # one of the following LoadModule lines:
    
    # prefork MPM: Implements a non-threaded, pre-forking web server
    # See: http://httpd.apache.org/docs/2.4/mod/prefork.html
    LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
    
    # worker MPM: Multi-Processing Module implementing a hybrid
    # multi-threaded multi-process web server
    # See: http://httpd.apache.org/docs/2.4/mod/worker.html
    #
    #LoadModule mpm_worker_module modules/mod_mpm_worker.so
    
    # event MPM: A variant of the worker MPM with the goal of consuming
    # threads only for connections with active processing
    # See: http://httpd.apache.org/docs/2.4/mod/event.html
    #
    #LoadModule mpm_event_module modules/mod_mpm_event.so
    
    0 讨论(0)
提交回复
热议问题