【问题标题】:How to find what MPM model Apache is using in Linux (worker, prefork or event)如何找到 Apache 在 Linux 中使用的 MPM 模型(worker、prefork 或 event)
【发布时间】:2011-09-07 16:46:08
【问题描述】:

我可以从哪里获得有关我的 Linux 系统中使用哪种 MPM Apache 的信息?

【问题讨论】:

    标签: apache apache2


    【解决方案1】:
    httpd -V
    

    然后查找Server MPM 行。

    例子:

    # httpd -V
    Server version: Apache/2.2.15 (Unix)
    Server built:   Aug  2 2013 08:02:15
    Server's Module Magic Number: 20051115:25
    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"
    

    【讨论】:

    • comments beneath the currently accepted answer 中提到的类似,在某些系统(例如Ubuntu)上,您应该使用apache2 -V
    • apache2 -V 看起来不像上面的输出(对我来说),但是 apachectl -V 可以。
    【解决方案2】:

    注意到之前的答案没有提到apachectl

    [dlam@some-ubuntu-box~] $apachectl -V | grep -i mpm

    服务器 MPM:事件

    --

    [dlam@some-fedora-box:~] $httpd -V | grep -i mpm

    服务器 MPM:预分叉

    【讨论】:

    • 另一个选项是使用以下命令列出 Compiled in modules:/usr/sbin/apache2 -l 在输出中查找 worker.c、prefork.c 或 event.c,因为其中只有一个会出现,表明您的 apache2 正在使用的相应 MPM 模块。
    • @okwap 来自@JorgeeFG 回答这个a2query -M 在Ubuntu 上工作
    • 对我来说这是唯一的工作方法,因为所有其他方法都没有显示任何 MPM。 apach2 -V 显示“服务器 MPM:”,仅此而已。在我的情况下,“事件”已启用。
    【解决方案3】:

    在 Ubuntu 14.04 中

    a2query -M
    

    告诉eventpreforkworker

    您可以通过在/etc/apache2 中添加mpm_<chosen> 的符号链接从mods-availablemods-enabled 来更改它。

    一次只允许一个。

    【讨论】:

    • 正是我需要的!谢谢!
    • 由于某种原因,在我的 (AWS) Ubuntu 14.04 上,没有定义任何必需的环境变量,因此其他解决方案都不起作用。这个做到了。
    【解决方案4】:

    您可以通过检查哪些模块使用 Apache 编译来查看这一点。

    查看以下命令的输出:

    # httpd -l
    

    从那里寻找prefork.c

    【讨论】:

    • 我喜欢@user131003 的回答,因为它用简单的英文告诉你:“Server MPM: Prefork threaded: no”
    【解决方案5】:

    如果是linux的话,默认应该是prefork。阅读here 了解有关 apache mpm 的更多信息。

    【讨论】:

      猜你喜欢
      • 2012-01-11
      • 2012-12-02
      • 2017-09-13
      • 2013-04-08
      • 1970-01-01
      • 2018-02-25
      • 2013-06-21
      • 2011-12-30
      • 1970-01-01
      相关资源
      最近更新 更多