如何增加在 Windows 7 下运行的 Apache 的堆栈大小? [英] How do I increase the stack size for Apache running under Windows 7?

查看:24
本文介绍了如何增加在 Windows 7 下运行的 Apache 的堆栈大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我在 Windows 7 下的 Apache 服务器上运行 cakePHP 应用程序时出现堆栈溢出.

I think I am getting stack overflows running a cakePHP application on an Apache server under Windows 7.

推荐答案

这个问题在 Windows 平台上更常见,因为 Apache 的默认堆栈大小较小.与 Unix/Linux 平台上的 8 MB 不同,Windows 上的默认堆栈大小为 1 MB.这可能是一个原因,为什么一些例如 PHP 脚本在 Linux 上正常工作,但导致 Apache 在 Windows 上崩溃.

This problem happens more often on Windows platform, because of smaller Apache's default stack size. There is 1 MB default stack size on Windows, unlike 8 MB on Unix/Linux platforms. It could be a reason, why some for example PHP scripts works properly on Linux, but cause crash of Apache on Windows.

此外,崩溃是无声的(分段错误),没有错误消息,Apache 只是停止响应并重新启动子进程.浏览器无法获取数据并呈现空白页面,因此很难确定是什么问题.

Furthermore, the crash is silent (segmentation fault), there is no error message, Apache just stops responding and the child process is restarted. Browser gets no data and renders a blank page, so it's a bit difficult to decide what's wrong.

在使用PHP 中的长正则表达式时,这是一个常见问题.

It's a common problem when working with long regular expressions in PHP.

Apache 的错误日志中只有一个通知,表明子进程崩溃了:

There is one notice in Apache's error log only, which tells, that child process crashed:

Parent: child process exited with status ... -- Restarting

更改 Apache 堆栈大小的最佳方法是使用 Apache 配置文件中的 ThreadStackSize 指令.Apache 的文档中有对 ThreadStackSize 指令的描述:http://httpd.apache.org/docs/2.2/mod/mpm_common.html#ThreadStackSize

The best way to alter the Apache's stack size is using the ThreadStackSize directive in the Apache's configuration file. There is a description of the ThreadStackSize directive in Apache's documentation: http://httpd.apache.org/docs/2.2/mod/mpm_common.html#ThreadStackSize

因此在 Windows 上增加 Apache 的堆栈大小可能如下所示:

So increase of the Apache's stack size on Windows might looks like this:

<IfModule mpm_winnt_module>
   ThreadStackSize 8388608
</IfModule>

这些行应该放在 Apache 的配置文件中.为简单起见,您可以将其放入 httpd.conf.或者更好(但不是必需的),将其放入 httpd-mpm.conf 文件并在 httpd.conf 中取消注释此行:

These lines should be put in the Apache's configuration file. For simplicity, you could put it to httpd.conf. Or better (but not necessary), put it to httpd-mpm.conf file and in httpd.conf uncomment this line:

Include conf/extra/httpd-mpm.conf

它将 Apache 的堆栈大小设置为 8 MB,因此它与 Linux 上的默认值相同.

It sets Apache's stack size to 8 MB, so it's the same as a default value on Linux.

别忘了重启 Apache!:)

这篇关于如何增加在 Windows 7 下运行的 Apache 的堆栈大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆