Nginx 出現 500 Error 修復 (too many open file, connection)
Nginx 出現 500 Error, 錯誤訊息只能從 Log 查到, 有遇到下述兩種狀況:
- socket() failed (24: Too many open files) while connecting to upstream
- 512 worker_connections are not enough while connecting to upstream
在此紀錄解決方法.
Nginx "Too many open files" 修復
錯誤訊息
2011/05/01 23:00:49 [alert] 7387#0: *6259768 socket() failed (24: Too many open files) while connecting to upstream, client: 123.123.123.123, server: www.example.com, request: "GET [[/]] HTTP/1.1", upstream: "fastcgi://127.0.0.1:1234", host: "www.example.com"
解法
- $ ulimit -n # 看目前系統設定的限制 (ulimit -a # 可查看全部參數)
1024
- vim /etc/security/limits.conf # 由此檔案設定 nofile (nofile - max number of open files) 的大小
# 增加/修改 下述兩行
* soft nofile 655360
* hard nofile 655360 - ulimit -n # 登出後, 在登入, 執行就會出現此值
655360
Nginx "512 worker_connections are not enough" 修復
錯誤訊息
2011/05/01 23:21:21 [alert] 19973#0: *6325881 512 worker_connections are not enough while connecting to upstream, client: 123.123.123.123, server: www.example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:1234", host: "www.example.com"
解法
- /etc/nginx/nginx.conf
worker_connections 10240;
- 參考 Nginx CoreModule
worker_processes 2;
worker_rlimit_nofile 10240;
events {
# worker_connections 10240;
}
Nginx 的 connection 增加後, 整體速度會變慢很多, 主要原因是 php-cgi 不夠用, 所以要作以下調整.
php-cgi was started with phpfcgid_children="10" and phpfcgid_requests="500"
ab was run on another server, connect via a switch using GBit ethernet
參考此篇設定: PHP performance III -- Running nginx
- vim /etc/nginx/nginx.conf
worker_connections 10240;
worker_rlimit_nofile - vim /etc/init.d/php-fcgi
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000
改成
PHP_FCGI_CHILDREN=150
PHP_FCGI_MAX_REQUESTS=10240 - 上述文章的 phpfcgid_stop(), 寫得還不錯, 有需要可以用看看.
phpfcgid_stop() {
echo "Stopping $name."
pids=`pgrep php-cgi`
pkill php-cgi
wait_for_pids $pids
}
转载于:https://blog.51cto.com/291856/1150351
Nginx 出現 500 Error 修復 (too many open file, connection)相关推荐
- Linux配置Nginx与PHP-FPM出现[error] 80143#0: *1 connect() failed (111: Connection refused) while connectin
原因是只启动了nginx 没有启动php-fpm /usr/local/sbin/php-fpm [root@localhost ~]# ps aux | grep 'php-fpm' root 80 ...
- 【转】nginx提示:500 Internal Server Error错误的解决方法
[转]nginx提示:500 Internal Server Error错误的解决方法 参考文章: (1)[转]nginx提示:500 Internal Server Error错误的解决方法 (2) ...
- browser html page iconic show error : 瀏覽器html頁面小圖標按鈕出現錯誤
browser html page iconic show error : 瀏覽器html頁面小圖標按鈕出現錯誤 下載一個新的瀏覽器,問題仍然在,注冊表出問題老.
- overwrite linux,在linux下的使用復制命令cp,不讓出現“overwrite”(文件覆蓋)提示的方法。(轉)...
在linux下的使用復制命令cp,不讓出現"overwrite"(文件覆蓋)提示的方法. 一般我們在使用cp命令時加上-f選項,希望不讓出現"overwrite" ...
- XMD RAC(Oracle 9i) 存儲修復處理
處理技朮﹕ [root@DELL-RAC02 root]# powermt display dev=all Pseudo name=emcpoweri CLARiiON ID=CK2000407000 ...
- linux开机报ata错误,Linux 系統出現 ATA SError DevExch 的錯誤解法
Linux 遇到硬碟快壞掉,然後半殘的情況,有 RAID1 是不用怕資料遺漏,只是機器的 Loading 變重,速度變很慢~ (如同此篇文章:Linux Soft RAID1 硬碟半殘的偵測確認.移除 ...
- linux 内核裁剪不当 死机,Linux編譯x86架構內核出現_stack_chk_guard未定義錯誤
背景 android模擬器運行於virtualbox中,而virtualbox運行於x86架構的pc端,所以android及其Linux內核都編譯成x86架構.當virtualbox的vt未開啟的情況 ...
- ie11 no java plugin,修復Javascript在IE11中不起作用
說明 To Fix (Javascript not working in IE11) error you need to follow the steps below: STEP 1: STEP 2: ...
- 7種解決方案修復請將磁片插入磁碟機
使用USB隨身碟時,您可能會收到"請將磁片(或光碟片)插入USB磁碟機(或光碟機)"的錯誤消息.因此,本文將重點介紹如何解決該問題,並指導您如何使用Bitwar Data Reco ...
最新文章
- Java 树形结构数据生成--不需要顶级节点
- 从Spring-Session源码看Session机制的实现细节
- Java---简易自动取货机
- oracle数据本机自动备份
- mysql基本架构_MySQL的基本架构
- 清远职业技术学院php,清远职业技术学院2020招生录取分数线
- 用java实现etcd分布式锁_etcd分布式锁及事务
- 课程设计之第二次冲刺----第八天
- 网络编程套接字Socket
- mysql text 性能_MySQL - text 性能优化--记录一
- 程序员「在知乎装逼被怼」,决定用『面试』证明自己
- Java web课程设计-购物系统
- Linux 桌面玩家指南:02. 以最简洁的方式打造实用的 Vim 环境
- [算法总结] LCA倍增法 dfs
- 分享一个自动外呼系统案例
- USB 对拷线材 YYDS
- 深度优先和广度优先的理解
- 又一所985大学改考408!中国海洋大学计算机专硕
- 关于软件开发外包,你应该注意的细节
- ORA-01846:周中的日无效