Article ID: 115139, created on Apr 10, 2013, last review on Aug 12, 2014

  • Applies to:
  • Plesk 12.5 for Linux
  • Plesk 12.0 for Linux
  • Plesk 11.0 for Linux
  • Plesk 11.5 for Linux
  • Plesk 10.3 for Linux/Unix

问题

当启用了 Nginx 支持且有很多域(超过 256 个),Nginx 会出现以下错误:
 
2012-11-08T20:13:34+07:00 ERR (3): Apache config (13523804010.47553900) generation failed: nginx: [emerg] open() "/var/www/vhosts/test255.tld/statistics/logs/proxy_access_ssl_log" failed (24: Too many open files)
nginx: configuration file /etc/nginx/nginx.conf test failed
 

原因

Nginx 虚拟主机为每个虚拟主机打开了四个日志文件:
 
1. proxy_access_log
2. proxy_access_ssl_log
3. webmail_access_log
4. webmail_access_ssl_log
 

解决方案

此问题将会在未来的更新中得以修复,也会创建相应的知识库文章。 如果您想要收到有关新知识库文章的通知可以订阅有关 Parallels Plesk Panel 产品的文章。
 

解决方案

1. 在 Nginx 配置中设置需要的 ULIMIT 值:

Debian/Ubuntu:
# echo 'ULIMIT="-n 4096"' >> /etc/default/nginx

RHEL/CentOS/openSUSE:
# echo 'ULIMIT="-n 4096"' >> /etc/sysconfig/nginx

2. 通过运行以下命令来下载和应用所需补丁。 第一个命令会创建已修复原文件的备份并把该备份放入 /root 目录:
 
# cp /etc/init.d/nginx /root/nginx.backup

Debian/Ubuntu:
# wget http://kb.parallels.com/Attachments/22839/Attachments/nginx.debian-ubuntu.patch
# patch /etc/init.d/nginx nginx.debian-ubuntu.patch

RHEL/CentOS:
# wget http://kb.parallels.com/Attachments/22839/Attachments/nginx.redhat-centos.patch
# patch /etc/init.d/nginx nginx.redhat-centos.patch

openSUSE:
# wget http://kb.sp.parallels.com/Attachments/22839/Attachments/nginx.suse.patch
# patch /etc/init.d/nginx nginx.suse.patch


3. 更改 root 和 psaadm 用户可打开文件描述符的限制:
# egrep "root|psaadm" /etc/security/limits.conf
root hard nofile 4096
root soft nofile 4096
psaadm hard nofile 4096
psaadm soft nofile 4096

注意: 修改生效需要重新登录终端。

4. 重启 sw-cp-server 和 Nginx 服务:
# /etc/init.d/sw-cp-server restart
# /etc/init.d/nginx restart

然后重新生成 web-server 配置:
# /usr/local/psa/admin/sbin/httpdmng --reconfigure-all

其他信息

因为任何 Parallels Plesk Panel 11.x 微更新都还未包含热修复,所以文件 /etc/init.d/nginx 将会在未来安装微更新的过程中被覆盖。

其它方案时添加 ulimit -n 32768 到脚本 nginx-config 的开端:
 
/usr/local/psa/admin/sbin/nginx-config
--->8---
#!/usr/bin/env bash
ulimit -n 32768

...
 ---8<---

记得运行 httpdmng 来应用修改:
 
# /usr/local/psa/admin/sbin/httpdmng --reconfigure-all

Attachments

0a53c5a9ca65a74d37ef5c5eaeb55d7f 56797cefb1efc9130f7c48a7d1db0f0c a914db3fdc7a53ddcfd1b2db8f5a1b9c 29d1e90fd304f01e6420fbe60f66f838 01bc4c8cf5b7f01f815a7ada004154a2 2a5151f57629129e26ff206d171fbb5f e335d9adf7edffca6a8af8039031a4c7 aea4cd7bfd353ad7a1341a257ad4724a 742559b1631652fadd74764ae8be475e f4ce8084cb23619ef5fe9428ecc388ea dd0611b6086474193d9bf78e2b293040

Email subscription for changes to this article