NGINX 中的 Laravel 应用程序抛出 502 错误网关

NGINX 中的 Laravel 应用程序抛出 502 错误网关

我已经配置了 NGINX 以在我的 FTP 目录中执行我的 laravel 应用程序。但是,当我访问我的网站时,我收到 502 错误网关。

我的配置如下:

server {

    server_name exoscape.co.uk;

    root            /home/exoscapeftp/ftp/ExoscapeWebsite/public;

    # Disallow access to hidden files (.htaccess, .git, etc.)
    location ~ /\. {
        deny all;
    }

    # Some locations will never contain PHP files, handle it in the server
    location ~ ^/(robots.txt|favicon.ico)(/|$) {
        try_files $uri =404;
    }

    location = /index.php {
        # Disable direct access to the source code of index.php. If you have a
        # Laravel route for '/index.php', copy the @php_router block below.
        return 404;
    }

    location / {
        # Try to serve the static files, otherwise call into PHP
        try_files $uri @php_router;
    }

    location @php_router {
        include fastcgi_params;
        # If you move index.php outside public/, adjust it here.
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
        fastcgi_pass unix:/var/run/php7.0-fpm.sock;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/exoscape.co.uk/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/exoscape.co.uk/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
}

我已确保我使用的是正确的 PHP 版本,使用时php --ini显示我正在使用 7.0。我已确保文件路径正确。任何帮助都值得感激!

更新:

我的路径php7.0-fpm.sock不正确。它被包裹在子目录中php。现在已被替换为:

fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

清除浏览器缓存、重新加载 nginx 配置后,仍然收到 502 错误。

相关内容