[英]How to check the nginx run the same version of php version on Ubuntu?
I just install PHP on the Ubuntu server in the Digitalocean and create a simple PHP file just for testing called phpinfo.php
and the contains is:我只是在 Digitalocean 的 Ubuntu 服务器上安装 PHP 并创建一个简单的 PHP 文件,仅用于测试,名为
phpinfo.php
,其中包含:
<?php phpinfo();
When I visit the file I got this error:当我访问该文件时,出现此错误:
I got this error: 502 Bad Gateway nginx/1.18.0 (Ubuntu)
I check the errors in nginx's error log and got this one:我检查了 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"
check php version is :检查 php 版本是:
PHP 7.4.10 (cli) (built: Sep 9 2020 06:36:30) ( NTS )
What is the problem ?问题是什么 ?
how can I check if Nginx using the same version of PHP 7.4如何检查 Nginx 是否使用相同版本的 PHP 7.4
You have to check php7.*-fpm.sock
if it's 4 or 2你必须检查
php7.*-fpm.sock
如果它是 4 或 2
First, run this command首先,运行这个命令
sudo vim /etc/nginx/sites-available/YOUR.DOMAIN.COM
you will get something like this:你会得到这样的东西:
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;
}
}
Change the version of PHP to 7.4
将 PHP 版本更改为
7.4
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
Save file保存存档
Then restart Nginx:然后重启Nginx:
sudo service nginx restart
Now visit your app with the name of the file and you will get the PHP page version现在使用文件名访问您的应用程序,您将获得 PHP 页面版本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.