代码之家  ›  专栏  ›  技术社区  ›  Jerome WAGNER

linux和i18n上的Apache:生成进程还是线程?

  •  0
  • Jerome WAGNER  · 技术社区  · 15 年前

    当我收到一个HTTP请求时,会选择一个子进程来处理该请求,并且在第一个请求完成之前,这个进程不会处理另一个用户的另一个请求,这是真的吗?

    我问这个问题是因为PHP的一个限制:

    The locale information is maintained per process, not per thread.
    If you are running PHP on a multithreaded server API like IIS or Apache
    on Windows, you may experience sudden changes in locale settings while a script
    is running, though the script itself never called setlocale(). This happens due
    to other scripts running in different threads of the same process at the same
    time, changing the process-wide locale using setlocale().
    
    1 回复  |  直到 12 年前
        1
  •  0
  •   Artyom    15 年前

    通常,如果使用mpm prefork,那么每个PHP实例都有自己的进程,因此 更改区域设置是安全的,如果使用mpm worker或mpm event,则不安全。

    另外,如果您在任何服务器后面以fastcgi进程的形式运行PHP,那么它也会分叉,并且每个连接都有一个进程。所以它也应该是安全的。

    笔记:

    • 一般来说,在Linux下运行PHP时没有理由不使用mpm prefork。
    • 在windows下没有fork这样的东西,所以apache在windows下是多线程的
    推荐文章