【发布时间】:2017-03-25 09:14:09
【问题描述】:
我已经在亚马逊 ec2 实例上安装了 php7 和 nginx,在 yii2 中出现以下错误。
2016/11/11 07:00:33 [error] 11220#0: *14 upstream timed out (110: Connection timed out)
while reading response header from upstream, client: XXX.XX.XXX.111, server:
example.com, request: "POST /backend/web/index.php?r=site%2Flogin HTTP/1.1",
upstream: "fastcgi://127.0.0.1:9000", host: "example.com",
referrer: "http://example.com/backend/web/index.php?r=site%2Flogin"
下面是我的 nginx 配置文件。 (/etc/nginx/conf.d/virtual.conf)
server {
charset utf-8;
client_max_body_size 128M;
listen 80;
server_name example.com;
location / {
root /path/to/root;
index index.php index.html index.htm;
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php?$args;
}
error_page 404 /errors/404.html;
location = /errors/404.html {
root /path/to/root;
}
error_page 500 502 503 504 /errors/50x.html;
location = /errors/50x.html {
root /path/to/root;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /path/to/root;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass /var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
try_files $uri =404;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
我已经尝试做以下但没有运气:(
location / {
...
proxy_read_timeout 300;
...
}
【问题讨论】:
-
检查您的代码是否有错误,我们在修复 php 代码后解决了类似的问题。喜欢这个答案:stackoverflow.com/questions/26070299/…
标签: nginx amazon-ec2 yii2 php-7