【问题标题】:Getting 502 setting up Laravel 4 on Nginx machine获取 502 在 Nginx 机器上设置 Laravel 4
【发布时间】:2014-02-12 20:07:10
【问题描述】:

我最初的错误是这样的:

nginx configuration for Laravel 4

但是在从多个论坛主题的建议中大量修改 Nginx 配置服务器块后,我要么得到 same 错误,其中显示第一页,但任何使用路由的链接都返回 404,或者我得到一个 502。

/nginx/sites-available/默认:

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,服务器:,请求:“GET / HTTP/1.1”,上游: “fastcgi://127.0.0.1:9000”,主机:“xxx.xxx.xxx.xxx”

【问题讨论】:

  • 你有/etc/php5/fpm/pools/ 文件夹吗?
  • 我有 /etc/php5/fpm/pool.d/www.conf @MohammadAbuShady
  • 看看里面有一行写着listen,你会发现2,但只有1会被取消注释,它是什么意思?
  • 听 = /var/run/php5-fpm.sock @MohammadAbuShady

标签: php nginx laravel laravel-4


【解决方案1】:

看到你的问题是你的 php 实际上并没有监听端口 9000,尝试替换

fastcgi_pass 127.0.0.1:9000;

有了这个

fastcgi_pass unix:/var/run/php5-fpm.sock

然后重新加载nginx

sudo service nginx reload

您的502 将消失

【讨论】:

  • '2014/01/23 20:21:46 [error] 14274#0: *112 connect() 连接到上游时失败(111:连接被拒绝),客户端:xxx.xxx.xxx .xxx,服务器:,请求:“GET / HTTP/1.1”,上游:“fastcgi://127.0.0.1:9000”,主机:“xxx.xxx.xxx.xxx”'@MohammadAbuShady
  • 我不确定我打错了什么,但在你的初始回答之后,我也开始收到 403 错误。从这个答案stackoverflow.com/questions/19285355/… 复制代码然后仔细查看差异,fastcgi_pass unix:/var/run/php5-fpm.sock 肯定在那里。
  • 我在 laravel forge 上收到了同样的错误信息。对我来说,重启服务器就可以了。
  • @AlexanderTaubenkorb 可能你的 php 服务没有运行,并且重新启动它。
猜你喜欢
  • 2014-10-17
  • 1970-01-01
  • 2014-06-28
  • 2019-02-01
  • 2020-09-01
  • 2014-02-01
  • 2013-07-04
  • 2020-04-06
  • 1970-01-01
相关资源
最近更新 更多