Nginx启动报错Cannot allocate memory

本文转载自: https://www.93bok.com

前言

今天改了nginx的一个配置参数,所以就reload了一下,我去,竟然报错了Cannot allocate memory起不来,日志报错如下:


  • 报错如下图
    Pr3ihn.png
[alert] 21470#0: mmap(MAP_ANON|MAP_SHARED, 536870912) failed (12: Cannot allocate memory)

解决

1. 查看一下内存还剩多少
free -m

              total        used        free      shared  buff/cache   available
Mem:            992         427          77          81         487         314
Swap:             0           0           0

2. 修改配置文件
vim /etc/nginx/nginx.conf

fastcgi_cache_path /data/www/wordpress/fastcgi/ngx_fcgi_cache levels=2:2 keys_zone=ngx_fcgi_cache:500m inactive=30s max_size=5g;

  • 把上边的500m改成free内存的数量即可,但是也不要一点不剩,这里我改成了50m
3. 修改完配置文件之后测试一下配置文件是否通过检测
nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful
4. 重启nginx成功

猜你喜欢

转载自www.cnblogs.com/93bok/p/12424895.html
今日推荐