net::ERR_CONNECTION_REFUSED 与 Nginx 和 Laravel 5

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29863780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:26:34  来源:igfitidea点击:

net::ERR_CONNECTION_REFUSED with Nginx and Laravel 5

phplaravelnginxlaravel-5

提问by imperium2335

I have just installed a fresh copy of Laravel 5 into /var/www.

我刚刚将 Laravel 5 的新副本安装到/var/www.

When I browse to the server I get net::ERR_CONNECTION_REFUSED.

当我浏览到服务器时,我得到 net::ERR_CONNECTION_REFUSED。

My Nginx config (default) is:

我的 Nginx 配置(默认)是:

server {
    listen 80;

    root /var/www/public;
    index index.php index.html index.htm;

    server_name _;

    location / {
            try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

}

}

Any idea what I'm doing wrong?

知道我做错了什么吗?



I am also confused about sites-enabled and sites-available. Where should default actually go?

我也对启用站点和可用站点感到困惑。默认值实际上应该去哪里?

I have moved default from sites-available to sites-enabled and I am now getting a 403 with "Access denied".

我已将默认站点从可用站点移至启用站点,现在我收到了“拒绝访问”的 403。

回答by Kyle

You probably got net::ERR_CONNECTION_REFUSED because you hadn't told nginx what port to listen on (note the listen 80line in your config file), so you were trying to a port that wasn't open - hence the connection refused error.

你可能得到 net::ERR_CONNECTION_REFUSED 因为你没有告诉 nginx 要监听的端口(注意listen 80你的配置文件中的那一行),所以你试图访问一个没有打开的端口 - 因此连接被拒绝错误。

As for sites-availablevs sites-enabled, that's a Debian/Ubuntu thing to make sites easier to manage - you can have many sites configured in sites-available, but only run specific ones by adding a link in sites-enabledpointing at the respective config file in sites-available.

至于sites-availableVS sites-enabled,这是一个Debian / Ubuntu的东西,使网站更容易管理-你可以有很多网站在配置sites-available通过添加一个链接,但只运行特定的人sites-enabled在各自的配置文件指向sites-available

As an example, my sites-enabledfolder has

例如,我的sites-enabled文件夹有

lrwxrwxrwx 1 root root 40 Feb  8 07:53 site.net -> /etc/nginx/sites-available/site.net

No copying, just a link to sites-available.

没有复制,只是一个指向可用站点的链接。



For your 403 error, look in your error log for what precisely is failing. It should be located at /var/log/nginx/error.log- look for error_login your main conf file to get the exact location.

对于您的 403 错误,请查看您的错误日志,了解究竟是什么失败了。它应该位于/var/log/nginx/error.log-error_log在您的主 conf 文件中查找以获取确切位置。