php - Apache /PHP/PHP-FPM : locale settings change themselves

标签 php apache

我遇到了 Apache 和 php-fpm 的错误:语言环境设置会随机更改。

以下是正确的语言环境设置:

Array
(
    [decimal_point] => .
    [thousands_sep] => 
    [int_curr_symbol] => 
    [currency_symbol] => 
    [mon_decimal_point] => 
    [mon_thousands_sep] => 
    [positive_sign] => 
    [negative_sign] => 
    [int_frac_digits] => 127
    [frac_digits] => 127
    [p_cs_precedes] => 127
    [p_sep_by_space] => 127
    [n_cs_precedes] => 127
    [n_sep_by_space] => 127
    [p_sign_posn] => 127
    [n_sign_posn] => 127
    [grouping] => Array
        (
        )

    [mon_grouping] => Array
        (
        )

)

这里是更改的设置:

Array
(
    [decimal_point] => ,
    [thousands_sep] =>  
    [int_curr_symbol] => EUR 
    [currency_symbol] => €
    [mon_decimal_point] => ,
    [mon_thousands_sep] =>  
    [positive_sign] => 
    [negative_sign] => -
    [int_frac_digits] => 2
    [frac_digits] => 2
    [p_cs_precedes] => 0
    [p_sep_by_space] => 1
    [n_cs_precedes] => 0
    [n_sep_by_space] => 1
    [p_sign_posn] => 1
    [n_sign_posn] => 1
    [grouping] => Array
        (
            [0] => 3
        )

    [mon_grouping] => Array
        (
            [0] => 3
        )

)

问题是随机发生的,我认为这是由于进程造成的,就像在 PHP doc 上所说的那样:

The locale information is maintained per process, not per thread. If you are running PHP on a multithreaded server API like IIS, HHVM 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().

当删除 php-fpm 并使用 FastCGI 时,问题不再出现。我怎样才能让它与 php-fpm 一起工作?问题发生在共享主机上(我们是提供主机的公司),我们确实需要 php-fpm 才能使用池。

提前致谢!

最佳答案

我不确定 apache,但 Nginx 有一个配置变量来设置工作线程。将 apache 配置为一次运行一个线程可能会解决您的问题,但当然这可能不是理想的性能。

关于php - Apache /PHP/PHP-FPM : locale settings change themselves,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30570418/

相关文章:

c# - 想做一个 php get_include_files() 增强

php - 不同的 php 按日期包含

php - 如何在 PHP 中回显/(斜杠)?

php - 使用 PHP 在后台运行管道 shell 命令

php - Laravel 5 如何从生产模式切换

Apache - 无法启用 TLS 1.0 或 TLS 1.1

linux - CGI 环境,读取最大大小是固定的?

php - URL 重写(SLUG)和 URL 重定向(htaccess)

php - 使用PHP将CSV数据导入mySQL

php - 寻找用于 windows 的 SMTP 服务器