【Nginx】解决 504 Gateway Time-out

文章目录

    • Nginx + FastCGI (php-fpm)
    • Nginx Proxy Timeout

常见的对应报错信息

“504 Gateway Timeout”
“504 Gateway Time-Out”
“504 Gateway Timeout NGINX”
“Nginx 504 Gateway Timeout”
“HTTP 504 Gateway Timeout”
“HTTP 504 Error”
“HTTP 504”
“Gateway Timeout (504)

Nginx + FastCGI (php-fpm)

更改php 配置文件,有两种不同的配置文件
方法一:
修改php.ini 文件
# 默认30s
max_execution_time = 300 

方法二:
/etc/php-fpm.d/www.conf
# 默认 60s
request_terminate_timeout = 600


更改Nginx 配置文件
添加 fastcgi_read_timeout 参数
location ~ .php$ {
	root /var/www/sites/nginxtips.com;
	try_files $uri =404;
	fastcgi_pass unix:/tmp/php5-fpm.sock;
	fastcgi_index index.php;
	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	include fastcgi_params;
	fastcgi_read_timeout 300;
}

# 重载 nignx 配置文件
systemctl reload nginx

Nginx Proxy Timeout

修改nginx.conf

proxy_connect_timeout       600;
proxy_send_timeout          600;
proxy_read_timeout          600;
send_timeout                600;

# 重载 nignx 配置文件
systemctl reload nginx

你可能感兴趣的:(服务器)