我原来的错误很像这样:
nginx configuration for Laravel 4
但是在从多个论坛主题的建议中大量修改Nginx配置服务器块后,我得到显示第一页的相同错误,但是使用路由的任何链接都返回404,或者我得到502。
/ nginx的/位点可用/默认值:
server {
listen 80;
server_name sub.domain.com;
set $root_path '/usr/share/nginx/html/laravel/public';
root $root_path;
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
错误日志:
2014/01/22 16:51:12 [错误] 14274#0:* 1 connect()失败(111: 连接拒绝)连接上游时,客户端: xxx.xxx.xxx.xxx,server :, request:“GET / HTTP / 1.1”,上游: “fastcgi://127.0.0.1:9000”,主持人:“xxx.xxx.xxx.xxx”
答案 0 :(得分:3)
看到你的问题是你的php实际上并没有收听端口9000,请尝试替换
fastcgi_pass 127.0.0.1:9000;
用这个
fastcgi_pass unix:/var/run/php5-fpm.sock
然后重新加载nginx
sudo service nginx reload
您的502
将会消失