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成功


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM