繁体   English   中英

如何检查 nginx 在 Ubuntu 上运行相同版本的 php 版本?

[英]How to check the nginx run the same version of php version on Ubuntu?

我只是在 Digitalocean 的 Ubuntu 服务器上安装 PHP 并创建一个简单的 PHP 文件,仅用于测试,名为phpinfo.php ,其中包含:

<?php phpinfo();

当我访问该文件时,出现此错误:

I got this error: 502 Bad Gateway nginx/1.18.0 (Ubuntu)

我检查了 nginx 错误日志中的错误并得到了这个:

2020/10/01 00:16:26 [crit] 23593#23593: *15 connect() to unix:/var/run/php/php7.2-fpm.sock failed (2: No such file or directory)
while connecting to upstream, client: 212.###.###.182, server: 46.#####.106, request: "GET /info.php HTTP/1.1", upstream: 
"fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "46..###.###106"

检查 php 版本是:

PHP 7.4.10 (cli) (built: Sep  9 2020 06:36:30) ( NTS )

问题是什么 ?

如何检查 Nginx 是否使用相同版本的 PHP 7.4

你必须检查php7.*-fpm.sock如果它是 4 或 2

首先,运行这个命令

sudo vim /etc/nginx/sites-available/YOUR.DOMAIN.COM

你会得到这样的东西:

server {
    listen 80;
    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name XXXXXXXXXX;

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

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }
}

将 PHP 版本更改为7.4

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

保存存档

然后重启Nginx:

sudo service nginx restart

现在使用文件名访问您的应用程序,您将获得 PHP 页面版本

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM