在/etc/apache2/apache2.conf中找不到prefork或worker设置-为什么?


10

我刚刚在Ubuntu 14.04 LTS系统上安装了Apache 2.4.7(Ubuntu),在/etc/apache2/apache2.conf中看不到prefork或worker设置。还没有为默认虚拟主机定义它们。我应该这样将它们自己设置在apache2.conf中吗?

<IfModule mpm_prefork_module>
    StartServers 2
    MinSpareServers 2
    MaxSpareServers 5
    MaxClients 200 #must be customized
    ServerLimit 200 #must be customized
    MaxRequestsPerChild 100
</IfModule>

Answers:


10

Ubuntu 14在下的单独文件中组织所有特定于模块的配置/etc/apache2/mods-available/,因此MPM prefork现在位于/etc/apache2/mods-available/mpm_prefork.conf


4

您是否在其中寻找这些设置/etc/apache2/conf.d/?这些设置可能保存在单独的随附文件中,以帮助打包。

我应该这样将它们自己设置在apache2.conf中吗?

<IfModule mpm_prefork_module>
    StartServers 2
    MinSpareServers 2
    MaxSpareServers 5
    MaxClients 200 #must be customized
    ServerLimit 200 #must be customized
    MaxRequestsPerChild 100
</IfModule>

是的,您可以将它们放在apache2.conf中(尽管确实要在conf.d/上述其他文件中查找它们)。

您的MaxRequestsPerChild似乎很低-可能成千上万。

如果您运行的是mod_php,则除非您有大量的RAM,否则应该大大降低MaxClients。


感谢您的回答。我的Apache安装没有conf.d/etc/apache2/。那怎么可能?
Maxim Koretskyi 2014年

抱歉,这是我在不进行14.04测试的情况下编写此答案所得到的。我只有12.04。他们要么更改了Apache的条件,要么发生了其他事情:)
thomasrutter

好的,我们将等待某人澄清此问题:)。您能详细说明一下Your MaxRequestsPerChild seems very low - this can be in the thousands. If you are running mod_php your MaxClients should be lowered significantly, unless you have many gigs of RAM.吗?
Maxim Koretskyi 2014年

默认的MaxRequestsPerChild是10000,这意味着每个进程每10,000个请求将仅重新启动一次。将此值降低到100似乎只会损害性能,除非您遇到特定的问题,例如不良的内存泄漏。对于MaxClients,使用mod_php可能需要将其从默认值降低,因为每个进程都非常大-除非您有许多GB的RAM。
thomasrutter 2014年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.