使用php-fpm7.4配置nginx 1.18

问题描述 投票:0回答:1

我想在nginx下运行php,我遇到了一些困难。我快完成了,但是,我遇到了错误502,不知道为什么。

我有Nginx 1.18,带有pmp的php7.4.x。我在以下目录中创建了一个php文件:/usr/share/nginx/html/info.php,但是在运行该文件时,出现错误502。这是默认配置文件的文件:

服务器{

    listen 80;
    root /usr/share/nginx/html;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name localhost;

    location / {
            try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }

}

我在某些情况下已经看到此行,但是当我执行“ nginx -t”时,它将失败。

包括摘要/ fastcgi-php.conf;

我仔细看了看,一切都在本地运行,一切都正常。我不明白。

php nginx configuration fastcgi
1个回答
0
投票

在上面的信息中,您有server_name example.com。检查那里的服务器名称是否正确。另外,请确保您的应用服务器正在运行,因为nginx无法访问,这就是为什么您看到502

© www.soinside.com 2019 - 2024. All rights reserved.