phpMyAdmin 502 错误网关 [CentOS7、nginx]

phpMyAdmin 502 bad gateway [CentOS7, nginx]

正在研究centos7和nginx。我可以使用 cerbot SSL 显示 index.html。 我安装了 phpmyAdmin 然后打开 https://mywebsite.com/phpMyAdmin/ 我有 502 Bad Gateway errir 谁能教我正确的方法吗?

这是我的日志。

2021/05/01 17:23:08 [error] 15816#15816: *103 connect() failed (111: Connection refused) while connecting to upstream, client: 125.xxx.xxx.xx, server: mywebsite.com, request: "GET /phpMyAdmin/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mywebsite.com"

2021/05/01 17:23:09 [error] 15816#15816: *103 open() "/var/www/html/favicon.ico" failed (2: No such file or directory), client: 125.xxx.xxx.xx, server: mywebsite.com, request: "GET /favicon.ico HTTP/1.1", host: "mywebsite.com"

这是我的 nginx.conf

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;

server {
    listen  443 ssl;
    server_name     mywebiste.com;


    root /var/www/html;

location / {
index index.php index.html index.htm;
}

location ^~ /blog {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://127.0.0.1:2368;
  }

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

这是我的 /etc/nginx/conf.d/default.conf 服务器 {

    location /phpMyAdmin {
        alias /usr/share/phpMyAdmin/;
        try_files $uri $uri/ /index.php;

        location ~ ^/phpMyAdmin/(.+\.php)$ {
            alias /usr/share/phpMyAdmin;
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/;
            include fastcgi_params;
            fastcgi_intercept_errors on;
            allow XXX.XXX.XX.XX;  # 
            deny  all;            # 
        }
    }     

}

UPDATE(I did Dear qwsj answer,after that Here is my update.)

我在 /usr/share/phpMyAdmin

安装了 phpmyadmin

ln -s /usr/share/phpMyAdmin /var/www/html/mywebisite/phpmyadmin

我打开https:///mywebisite/phpmyadmin/

错误日志说 “/var/www/html/mywebisite/phpmyadmin/”的目录索引被禁止,

在错误日志中 upstream: "fastcgi://127.0.0.1:9000" 但在配置中你使用了 unix 套接字(mb 你没有创建 reload/restart?)。

检查 php-fpm 配置(变量 listen),socket /var/run/php-fpm.sock/var/run/php-fpm/php-fpm.sock 的真实路径是什么?

此外,在此之后,检查 php-fpm 的监听权限,用户必须与 nginx config (nginx.conf) 中的用户相同。 PHP-FPM 池配置例如:

listen.owner = nginx
listen.group = nginx

Nginx 配置例如:

user nginx;

更新:请检查 SELinux 状态,需要禁用它:

[root ~]# sestatus
SELinux status:                 enabled
...

将 SELinux /etc/selinux/configSELINUX=enforcing 更新为 SELINUX=disabled。在此之后,需要重新启动。 重启后:

[root ~]# sestatus
SELinux status:                 disabled
[root ~]#

我的测试配置:

    location /phpMyAdmin {
        root /usr/share;
        index index.php index.html index.htm;
        location ~ ^/phpMyAdmin/(.+\.php)$ {
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_intercept_errors on;
        }
    }

不要创建符号链接ln -s /usr/share/phpMyAdmin /var/www/html/mywebisite/phpmyadmin,不需要