每次我尝试发布我的网站时,几分钟后就会出现 502 Bad Gateway 错误,并且在我的default-error.log
文件中我会反复出现此错误(文件大小为 360MB...):
2016/02/03 14:57:28 [error] 1044#1044: *7248 connect() to unix:/var/run/php/php7.0-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 123.456.78.90, server: default, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "domain.com"
服务器配置
- 操作系统:Ubuntu 14.04.3 LTS(GNU/Linux 3.13.0-71-generic x86_64)
- Nginx 版本:1.9.10
- PHP 版本 PHP 7.0.2-4+deb.sury.org~trusty+1 (cli) ( NTS )
- (我的服务器托管在 Digital Ocean 并且有 4GB RAM)。
nginx.conf:
server {
listen 80 default_server;
server_name default;
root /home/forge/default/public;
# FORGE SSL (DO NOT REMOVE!)
include logjam_fix;
# ssl_certificate;
# ssl_certificate_key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log on;
error_log /var/log/nginx/default-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
我是否遗漏了任何数据?
答案1
尝试增加最大打开文件数:
root@server $ sysctl fs.file-max=3000000000
编辑:
通常可以通过添加以下行使这些更改永久生效/etc/sysctl.conf
:
fs.file-max=3000000000