当前位置: 首页 > 知识库问答 >
问题:

nginx

端木望
2023-03-14

新发展

核心php错误日志如下,但网站特定的错误日志显示了这一点。我php.ini文件的内存是:

内存大小为1024;

所以这不是php的内存限制。我还禁用了所有插件,所以我的安全插件没有内存限制。

2014/12/13 16:12:40[错误]28264#0:*212 FastCGI在stderr中发送:“PHP消息:PHP致命错误:允许的内存大小为268435456字节,已在/var/www/中耗尽(尝试分配71字节)。。

我在wordpress插件运行一整批导入时遇到问题。我在启用nginx调试时出现此错误。结果是,我得到一个立即404错误后,我无法完全导入我的数据。

我很确定这是一个bug,但我找不到正确的答案来修复它。

请帮助。

到目前为止我所做的:

  • 它看起来像一个nginx错误,我的nginx版本很旧,所以我升级了。没有变化。
  • 它看起来和现在仍然看起来可能与php-fpm有关。我升级了。没有变化。
  • 我已经禁用了我所有的插件。没有变化。

服务器

  • CentOS 6.0
  • nginx v 1.0.15
  • PHP-FPM v 5.3.3(fpm-fcgi)
  • 运行3个流量很低的网站的网络服务器
  • PHP-FPM设置为ondemmand

PHP。ini配置:

  • pm=按需
  • pm.process_idle_timeout=50
  • pm.max_children=20
  • pm.start_servers=1
  • pm.min_spare_servers=3
  • pm.max_spare_servers=5
  • pm.max_requests=1024
  • pm.status_path= /status

我无法发布日志,请查看比较

Nginx日志:

[12-Dec-2014 06:35:49.398315] DEBUG: pid 13384, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 1 spare children
[12-Dec-2014 06:35:50.399474] DEBUG: pid 13384, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 1 spare children
[12-Dec-2014 06:35:51.400765] DEBUG: pid 13384, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 1 spare children
[12-Dec-2014 06:35:52.402053] DEBUG: pid 13384, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 1 spare children
[12-Dec-2014 06:35:53.403346] DEBUG: pid 13384, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 1 spare children
[12-Dec-2014 06:35:53.417762] DEBUG: pid 13384, fpm_got_signal(), line 72: received SIGCHLD
[12-Dec-2014 06:35:53.417836] DEBUG: pid 13384, fpm_children_bury(), line 254: [pool www] child 18327 has been killed by the process managment after 52.123053 seconds from start
[12-Dec-2014 06:35:53.417863] DEBUG: pid 13384, fpm_event_loop(), line 411: event module triggered 1 events
[12-Dec-2014 06:35:54.404978] DEBUG: pid 13384, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 0 spare children
[12-Dec-2014 06:35:54.687559] DEBUG: pid 13384, fpm_children_make(), line 421: [pool www] child 18397 started




[12-Dec-2014 06:35:54.687593] DEBUG: pid 13384, fpm_pctl_on_socket_accept(), line 536: [pool www] got accept without idle child available .... I forked
[12-Dec-2014 06:35:54.687602] DEBUG: pid 13384, fpm_event_loop(), line 411: event module triggered 1 events




[12-Dec-2014 06:35:55.406455] DEBUG: pid 13384, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 1 spare children
[12-Dec-2014 06:35:56.407633] DEBUG: pid 13384, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 1 spare children
[12-Dec-2014 06:35:57.408949] DEBUG: pid 13384, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 1 spare children
[12-Dec-2014 06:35:58.410111] DEBUG: pid 13384, fpm_pctl_perform_idle_server_maintenance(), line 362: [pool www] currently 0 active children, 1 spare children

PHP日志:

2014/12/12 06:35:02 [debug] 13350#0: *223 http header done
2014/12/12 06:35:54 [debug] 13350#0: accept on 0.0.0.0:80, ready: 1
2014/12/12 06:35:54 [debug] 13350#0: posix_memalign: 0000000002273A80:256 @16
2014/12/12 06:35:54 [debug] 13350#0: *226 accept: 66.249.67.123 fd:3
2014/12/12 06:35:54 [debug] 13350#0: *226 event timer add: 3: 60000:1418387814684
2014/12/12 06:35:54 [debug] 13350#0: *226 epoll add event: fd:3 op:1 ev:80000001
2014/12/12 06:35:54 [debug] 13350#0: accept() not ready (11: Resource temporarily unavailable)
2014/12/12 06:35:54 [debug] 13350#0: *226 malloc: 0000000002274AF0:1296
2014/12/12 06:35:54 [debug] 13350#0: *226 posix_memalign: 0000000002273BE0:256 @16
2014/12/12 06:35:54 [debug] 13350#0: *226 malloc: 000000000232F4B0:131072
2014/12/12 06:35:54 [debug] 13350#0: *226 posix_memalign: 00000000021F7590:4096 @16
2014/12/12 06:35:54 [debug] 13350#0: *226 http process request line
2014/12/12 06:35:54 [debug] 13350#0: *226 recv: fd:3 315 of 131072
2014/12/12 06:35:54 [debug] 13350#0: *226 http request line: "GET /stores/giltcity/page/78/ HTTP/1.1"
2014/12/12 06:35:54 [debug] 13350#0: *226 http uri: "/stores/giltcity/page/78/"
2014/12/12 06:35:54 [debug] 13350#0: *226 http args: ""
2014/12/12 06:35:54 [debug] 13350#0: *226 http exten: ""
2014/12/12 06:35:54 [debug] 13350#0: *226 http process request header line
2014/12/12 06:35:54 [debug] 13350#0: *226 http header: "Host: mydiscountman.com"
2014/12/12 06:35:54 [debug] 13350#0: *226 http header: "Connection: Keep-alive"
2014/12/12 06:35:54 [debug] 13350#0: *226 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
2014/12/12 06:35:54 [debug] 13350#0: *226 http header: "From: googlebot(at)googlebot.com"
2014/12/12 06:35:54 [debug] 13350#0: *226 http header: "Accept-Encoding: gzip,deflate"
2014/12/12 06:35:54 [debug] 13350#0: *226 http header: "User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
2014/12/12 06:35:54 [debug] 13350#0: *226 http header done
2014/12/12 06:37:11 [debug] 13350#0: accept on 0.0.0.0:80, ready: 1

Nginx全局配置/etc/Nginx/Nginx。形态:

user apache;
worker_processes 1;
pid /var/run/nginx.pid;


events {
worker_connections 768;
multi_accept on;
use epoll;
}

http {

# Let NGINX get the real client IP for its access logs
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;

# Basic Settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 20;
client_max_body_size 15m;
client_body_timeout 60;
client_header_timeout 60;
client_body_buffer_size  128k;
client_header_buffer_size 128k;
large_client_header_buffers 4 16k;
send_timeout 60;
reset_timedout_connection on;
types_hash_max_size 8192;
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 debug;

# Log Format
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

# Gzip Settings
gzip on;
gzip_static on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_min_length 512;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/css text/javascript text/xml text/plain text/x-component 
application/javascript application/x-javascript application/json 
application/xml  application/rss+xml font/truetype application/x-font-ttf 
font/opentype application/vnd.ms-fontobject image/svg+xml;

# Virtual Host Configs
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

Nginx网站配置 /etc/nginx/sites-available/testme:

server {
listen       80;
server_name  testme.XXXXXXX.com;

port_in_redirect off;
server_tokens off;
autoindex off;

client_max_body_size 15m;
client_body_buffer_size 128k;

access_log  /var/log/nginx/testme/access_log  main;
error_log   /var/log/nginx/testme/error_log;

root /var/www/testme;
index index.php  index.html index.htm;
try_files $uri $uri/ /index.php;

error_page  404              /404error.html;
location = /var/www/testme/404error.html {
    internal;
}

error_page  500              /500error.html;
location = /var/www/testme/500error.html {
    internal;
}

# Define default caching of 24h
expires 8s;
add_header Pragma public;
add_header Cache-Control "max-age=86400, public, must-revalidate, proxy-revalidate";

# Redirect server error pages to static 50x.html
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}

# Don't log robots.txt requests
location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

location /phpmyadmin {
auth_basic            "Restricted";
auth_basic_user_file  /var/www/testme/phpmyadmin/.htpasswd;
try_files $uri $uri/ index.html index.php;
index index.html index.htm index.php;
location ~ /\.ht {
    deny  all;
}
location ~* ^.+\.(css|js)$ {
    #try_files $uri $uri/;
    #root /var/www/testme/phpmyadmin;
    access_log off;
}
location ~ ^.+\.php {
    try_files $uri $uri/ *.php;
    fastcgi_split_path_info ^(.+.php)(.*)$;
    fastcgi_pass unix:/var/run/php-fpm.socket;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/testme$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_ignore_client_abort off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;

}
}

# Rewrite for versioned CSS+JS via filemtime
#    location ~* ^.+\.(css|js) {
#        rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
#        expires 31536000s;
#        access_log on;
#        log_not_found on;
#        add_header Pragma public;
#        add_header Cache-Control "max-age=31536000, public";
#    }

# Aggressive caching for static files
# If you alter static files often, please use 
# add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
location ~* \.    (asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|ogv|otf|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|t?gz|tif|tiff|ttf|wav|webm|wma|woff|wri|xla|xls|xlsx|xlt|xlw|zip)$ {
    expires 31536000s;
    access_log on;
    log_not_found on;
    add_header Pragma public;
    add_header Cache-Control "max-age=31536000, public";
}


location ~* (^(?!(?:(?!(php|inc)).)*/uploads/).*?(php)) {
set $php_root   $document_root;
    if ($request_uri ~* /phpmyadmin) {
    #set $php_root /usr/share;
    }

    try_files $uri = 404;
    fastcgi_split_path_info ^(.+.php)(.*)$;
    fastcgi_pass unix:/var/run/php-fpm.socket;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
    fastcgi_intercept_errors on;
    fastcgi_ignore_client_abort off;
    fastcgi_connect_timeout 3600;
    fastcgi_send_timeout 3600;
    fastcgi_read_timeout 3600;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
  }

}

PHP。伊尼

    [PHP]

    ;;;;;;;;;;;;;;;;;;;
    ; Quick Reference ;
    ;;;;;;;;;;;;;;;;;;;

    error_reporting = E_ALL & ~E_NOTICE

    extension=apc.so

    ;;;;;;;;;;;;;;;;;;;;
    ; Language Options ;
    ;;;;;;;;;;;;;;;;;;;;

    engine = On
    short_open_tag = Off
    asp_tags = Off
    precision = 14
    y2k_compliance = On
    zlib.output_compression = Off
    implicit_flush = Off
    unserialize_callback_func =
    serialize_precision = 100

    safe_mode = Off
    safe_mode_gid = Off
    safe_mode_include_dir =
    safe_mode_exec_dir =
    safe_mode_allowed_env_vars = PHP_
    safe_mode_protected_env_vars = LD_LIBRARY_PATH
    disable_functions =
    disable_classes =
    realpath_cache_size = 16k
    realpath_cache_ttl = 120

    ;;;;;;;;;;;;;;;;;
    ; Miscellaneous ;
    ;;;;;;;;;;;;;;;;;

    expose_php = On

    ;;;;;;;;;;;;;;;;;;;
    ; Resource Limits ;
    ;;;;;;;;;;;;;;;;;;;

    max_execution_time = 600
    set_time_limit = 600
    max_input_time = 300
    memory_limit = 2048M

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Error handling and logging ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    error_reporting = E_ALL & ~E_DEPRECATED
    display_errors = Off
    display_startup_errors = Off
    log_errors = On
    log_errors_max_len = 1024
    ignore_repeated_errors = Off
    ignore_repeated_source = Off
    report_memleaks = On
    track_errors = Off
    html_errors = Off
    error_log = /var/log/php-fpm/www-error.log


    ;;;;;;;;;;;;;;;;;
    ; Data Handling ;
    ;;;;;;;;;;;;;;;;;

    variables_order = "GPCS"
    request_order = "GP"
    register_globals = Off
    register_long_arrays = Off
    register_argc_argv = Off
    auto_globals_jit = On
    post_max_size = 384M
    magic_quotes_gpc = Off
    magic_quotes_runtime = Off
    magic_quotes_sybase = Off
    auto_prepend_file =
    auto_append_file =
    default_mimetype = "text/html"

    ;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Paths and Directories ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;

    doc_root =
    user_dir =
    enable_dl = Off
    cgi.fix_pathinfo=0

    ;;;;;;;;;;;;;;;;
    ; File Uploads ;
    ;;;;;;;;;;;;;;;;

    file_uploads = On
    upload_max_filesize = 512M

    ;;;;;;;;;;;;;;;;;;
    ; Fopen wrappers ;
    ;;;;;;;;;;;;;;;;;;

    allow_url_fopen = On
    allow_url_include = Off
    default_socket_timeout = 120

    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;

    ;;;;;;;;;;;;;;;;;;;
    ; Module Settings ;
    ;;;;;;;;;;;;;;;;;;;

    [Date]

    date.timezone = America/Chicago

    [filter]

    [iconv]

    [intl]

    [sqlite]

    [sqlite3]

    [Pcre]

    [Pdo]

    [Phar]

    [Syslog]

    define_syslog_variables  = Off

    [mail function]

    SMTP = localhost
    smtp_port = 25
    sendmail_path = /usr/sbin/sendmail -t -i
    mail.add_x_header = On

    [SQL]

    sql.safe_mode = Off

    [ODBC]

    odbc.allow_persistent = On
    odbc.check_persistent = On
    odbc.max_persistent = -1
    odbc.max_links = -1
    odbc.defaultlrl = 4096
    odbc.defaultbinmode = 1

    [MySQL]

    mysql.allow_persistent = On
    mysql.max_persistent = -1
    mysql.max_links = -1
    mysql.default_port =
    mysql.default_socket =
    mysql.default_host =
    mysql.default_user =
    mysql.default_password =
    mysql.connect_timeout = 300
    mysql.trace_mode = Off

    [MySQLi]

    mysqli.max_links = -1
    mysqli.default_port = 3306
    mysqli.default_socket =
    mysqli.default_host =
    mysqli.default_user =
    mysqli.default_pw =
    mysqli.reconnect = Off

    [PostgresSQL]

    pgsql.allow_persistent = On
    pgsql.auto_reset_persistent = Off
    pgsql.max_persistent = -1
    pgsql.max_links = -1
    pgsql.ignore_notice = 0
    pgsql.log_notice = 0

    [Sybase-CT]

    sybct.allow_persistent = On
    sybct.max_persistent = -1
    sybct.max_links = -1
    sybct.min_server_severity = 10
    sybct.min_client_severity = 10

    [bcmath]

    bcmath.scale = 0

    [browscap]

    [Session]

    session.save_handler = files
    session.save_path = "/var/lib/php/session"
    session.use_cookies = 1
    session.use_only_cookies = 1
    session.name = PHPSESSID
    session.auto_start = 0
    session.cookie_lifetime = 0
    session.cookie_path = /
    session.cookie_domain =
    session.cookie_httponly = 
    session.serialize_handler = php
    session.gc_probability = 1
    session.gc_divisor = 1000
    session.gc_maxlifetime = 1440
    session.bug_compat_42 = Off
    session.bug_compat_warn = Off
    session.referer_check =
    session.entropy_length = 0
    session.entropy_file =
    session.cache_limiter = nocache
    session.cache_expire = 180
    session.use_trans_sid = 0
    session.hash_function = 0
    session.hash_bits_per_character = 5
    url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

    [MSSQL]

    mssql.allow_persistent = On
    mssql.max_persistent = -1
    mssql.max_links = -1
    mssql.min_error_severity = 10
    mssql.min_message_severity = 10
    mssql.compatability_mode = Off
    mssql.timeout = 300
    mssql.secure_connection = Off




    [Tidy]

    tidy.clean_output = Off

    [soap]

    soap.wsdl_cache_enabled=1
    soap.wsdl_cache_dir="/tmp"
    soap.wsdl_cache_ttl=86400

共有1个答案

刘阳荣
2023-03-14

我认为您应该检查代码PHP强制执行,并应该优化导致缓冲区溢出的命令PHP。在代码上执行命令而不是增加内存限制。

因为我的公司有一些情况错误作为你。首先,我增加了开发的内存,但是在我们意识到不应该增加内存后,应该在代码上执行最佳。当它帮助你提高编程。

 类似资料:
  • 问题内容: 基本安装nginx后,您的文件夹只有一个文件: 该文件夹如何工作,我将如何使用它托管多个(单独的)网站? 问题答案: 只需添加另一种方法,您就可以为托管的每个虚拟域或站点使用单独的文件。您可以将默认副本作为每个副本的起点,并为每个站点进行自定义。 然后在启用站点的站点中创建符号链接。这样,您可以通过添加或删除符号链接并发布服务nginx重新加载来访问站点。 在进行站点维护时,您可以发挥

  • 问题内容: 我在Docker容器上安装了Nginx,并且正在尝试像这样运行它: 问题在于Nginx的工作方式,即初始进程会立即产生一个主要的Nginx进程和一些工作程序,然后退出。由于Docker仅监视原始命令的PID,因此容器将暂停。 如何防止容器停止?我需要能够告诉它绑定到第一个子进程,或者阻止Nginx的初始进程退出。 问题答案: 像所有行为良好的程序一样,可以配置为不自我守护。 使用htt

  • 问题内容: 我使用nginx作为前端服务器,我修改了CSS文件,但是nginx仍在使用旧文件。 我试图重新启动nginx,但没有成功,我已经用Google搜索,但是找不到清除它的有效方法。 一些文章说我们只能删除缓存目录:,但是我的服务器上没有这样的目录。 我现在该怎么办? 问题答案: 我遇到了完全相同的问题-我在Virtualbox中运行了Nginx。我没有打开缓存。但是看起来像已经设置好了,这

  • 问题内容: 这是我的配置: 回波用于测试。我隐藏了IP。 我正在尝试通过NGiNX从Redis获取会话数据。这就是为什么我安装HttpRedis的原因。 我不了解的是如何从Redis获取数据,然后将其放入变量中。所以我可以随便使用它。 问题答案: 使用NGiNX-Eval-Module:https : //github.com/vkholodkov/nginx-eval- module 这是您的操

  • 问题内容: 我试图建立一个Jenkins主节点和一个Jenkins从节点,其中Jenkins主节点位于另一台具有SSL终止的服务器上的Nginx反向代理之后。Nginx的配置如下: 在Jenkins主全局安全性配置中,JNLP代理的TCP端口设置为50000。端口50000设置为可从主机上的任何位置访问。 JNLP从站使用以下命令启动: JNLP从站无法连接到主站上已配置的JNLP端口: JNLP

  • 问题内容: 我正在尝试制作一个使用 Redis* 作为后端的 Java应用程序 。由于 Redis 是一个非常快速的键值存储,我想使用它,但是 redis 可以与1个客户端一起使用,因此它没有user:pass身份验证的选项。我想找到一种实现某种身份验证的方法,因此我尝试了带有 redis2 扩展名的 nginx 。我这样做是因为我可以使用 客户端证书 和HTTPS。但这使我的应用程序非常慢。 *

  • 本文向大家介绍Nginx 操作响应头信息的实现,包括了Nginx 操作响应头信息的实现的使用技巧和注意事项,需要的朋友参考一下 前置条件:需要编译 ngx_http_headers_module 模块,才支持 header 头信息操作 add_header 意思为将自定义的头信息的添加到响应头,指令为 add_header name value [always];,可以用在 http {}, se

  • 问题内容: 他们似乎遇到了类似的问题,但该解决方案对我不起作用。 基本上,每当我尝试启动uWSGI进程时,我总是遇到Nginx 502错误的网关屏幕。按照文档中的说明,我有两个独立的uwsgi进程正在运行。 当我运行websocket uwsgi实例时,得到以下信息: 这告诉我uwsgi实例运行正常。然后我运行我的下一个uwsgi进程,并且那里也没有错误日志… 当我导航到浏览器中的页面时,带有ha