Nginx 或 PHP FPM 忽略 php.ini 中的 memory_limit [英] Nginx or PHP FPM ignores memory_limit in php.ini

查看:30
本文介绍了Nginx 或 PHP FPM 忽略 php.ini 中的 memory_limit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务器信息:Ubuntu 服务器、Nginx、PHP FPM

Server info: Ubuntu Server, Nginx, PHP FPM

/etc/php5/fpm/php.ini 我有:memory_limit = 512M/etc/php5/fpm/php-fpm.conf 我有:php_admin_value[memory_limit] = 512M

in /etc/php5/fpm/php.ini I have: memory_limit = 512M in /etc/php5/fpm/php-fpm.conf I have: php_admin_value[memory_limit] = 512M

php_value[memory_limit] = 512M

我的 phpinfo 看起来像:

PHP 版本 5.3.10-1ubuntu3.6

My phpinfo looks like:

PHP Version 5.3.10-1ubuntu3.6

Linux snserver 3.2.0-40-generic #64-Ubuntu SMP Mon Mar 25 21:22:10 UTC 2013 x86_64 Mar 11 2013 14:34:24

Linux snserver 3.2.0-40-generic #64-Ubuntu SMP Mon Mar 25 21:22:10 UTC 2013 x86_64 Mar 11 2013 14:34:24

FPM/FastCGI

已禁用

/etc/php5/fpm 

加载的配置文件

/etc/php5/fpm/php.ini

扫描此目录以获取其他 .ini 文件/etc/php5/fpm/conf.d

Scan this dir for additional .ini files /etc/php5/fpm/conf.d

/etc/php5/fpm/conf.d/curl.ini、/etc/php5/fpm/conf.d/gd.ini、/etc/php5/fpm/conf.d/mcrypt.ini,/etc/php5/fpm/conf.d/memcache.ini,/etc/php5/fpm/conf.d/mysql.ini,/etc/php5/fpm/conf.d/mysqli.ini,/etc/php5/fpm/conf.d/pdo.ini,/etc/php5/fpm/conf.d/pdo_mysql.ini...

此服务器受 Suhosin 补丁 0.9.10 保护版权所有 (c) 2006-2007 Hardened-PHP 项目 版权所有 (c) 2007-2009 SektionEins GmbH

This server is protected with the Suhosin Patch 0.9.10 Copyright (c) 2006-2007 Hardened-PHP Project Copyright (c) 2007-2009 SektionEins GmbH

该程序使用 Zend 脚本语言引擎:Zend Engine v2.3.0,版权所有 (c) 1998-2012 Zend Technologies使用 Xdebug v2.2.2,版权所有 (c) 2002-2013,作者:Derick Rethans

This program makes use of the Zend Scripting Language Engine: Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies with Xdebug v2.2.2, Copyright (c) 2002-2013, by Derick Rethans

...

128M

20M

在/etc/nginx/nginx.conf中:

in /etc/nginx/nginx.conf:

    user www-data;

worker_processes 2;

pid /var/run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {
    client_max_body_size 20M;

    ##

    # Basic Settings

    ##
    fastcgi_buffers 16 16k;

    fastcgi_buffer_size 32k;

    proxy_buffers 4 512k;

    proxy_buffer_size 256k;

    proxy_busy_buffers_size 512k;

    fastcgi_read_timeout 3600;

    sendfile on;

    tcp_nopush on;

    tcp_nodelay on;

    keepalive_timeout 300;

    keepalive_requests 50;

    #ssl_ciphers HIGH:!aNULL:!MD5:!kEDH;

        #ssl_prefer_server_ciphers on;

        #ssl_protocols TLSv1;

        #ssl_session_cache shared:SSL:10m;

        #ssl_session_timeout 10m;

    types_hash_max_size 2048;

    # server_tokens off;

    # server_names_hash_bucket_size 64;

    # server_name_in_redirect off;

    include /etc/nginx/mime.types;

    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;

    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

<小时>

问题是当我更改 upload_max_filesize 大小时,phpinfo 将显示新值,但是当我更改 memory_limit 时,没有任何变化.我猜在某个地方 memory_limit 被覆盖了.但我找不到它.有人可以帮我吗?


The problem is when i change upload_max_filesize size then the phpinfo will show the new value, but when I change memory_limit then nothing changes. I guess in somewhere the memory_limit is overwrited. But i cannot find it. Can anyone help me?

推荐答案

你可以把 Nginx 去掉,它只是传递请求,它在 php-fpm 中运行你的 php 代码.

You can take Nginx out of the picture, it just passes the request on, it's in php-fpm running your php code.

你可以检查你的 suhosin 设置,suhosin.memory_limit.

you might check your suhosin settings, suhosin.memory_limit.

当你看到你的 phpinfo 输出时,应该有 2 列,master 和 local 用于 memory_limit,每列显示什么?

when you see your phpinfo output there should be 2 columns, master and local for memory_limit, what do these each show?

128M 是 php 5.3 中 memory_limit 的默认值

128M is the default for memory_limit in php 5.3

这篇关于Nginx 或 PHP FPM 忽略 php.ini 中的 memory_limit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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