这2天一个php站点,频繁出现 502 bad gateway,在 nginx配置文件添加以下项目:解决:
红色为添加项目:
server
{
listen 80;
server_name shop;
index index.html index.htm index.php;
root /home/ngixroot/shop2;
tcp_nodelay on;
fastcgi_keep_conn on;
fastcgi_connect_timeout 10000;
fastcgi_send_timeout 10000;
fastcgi_read_timeout 10000;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
location / {
if (!-e $request_filename) {
# rewrite ^/(.*)$ /index.php/$1 last;
# break;
}
}
location ~ \.php {
fastcgi_connect_timeout 10000;
fastcgi_send_timeout 10000;
fastcgi_read_timeout 10000;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# include fcgi.conf;
include fastcgi_params;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
location /status {
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
error_log logs/error1.log;
}