phpMyAdmin 502 网关错误 [CentOS7, nginx] [英] phpMyAdmin 502 bad gateway [CentOS7, nginx]

查看:133
本文介绍了phpMyAdmin 502 网关错误 [CentOS7, nginx]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 centos7 和 nginx.我可以使用 cerbot SSL 显示 index.html.我安装了 phpmyAdmin 然后我打开 https://mywebsite.com/phpMyAdmin/我收到 502 错误网关错误有人可以教我正确的方法吗?

这是我的日志.

2021/05/01 17:23:08 [error] 15816#15816: *103 connect() failed (111: Connection denied) while connected to upstream, client: 125.xxx.xxx.xx,服务器:mywebsite.com,请求:GET/phpMyAdmin/HTTP/1.1",上游:fastcgi://127.0.0.1:9000",主机:mywebsite.com"2021/05/01 17:23:09 [错误] 15816#15816:*103 open() "/var/www/html/favicon.ico"失败(2:没有这样的文件或目录),客户端:125.xxx.xxx.xx,服务器:mywebsite.com,请求:GET/favicon.ico HTTP/1.1",主机:mywebsite.com"

这是我的 nginx.conf

http {包括/etc/nginx/mime.types;default_type 应用程序/八位字节流;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;发送文件;#tcp_nopush on;keepalive_timeout 65;#gzip 上;包括/etc/nginx/conf.d/*.conf;服务器 {听 443 ssl;server_name mywebiste.com;根/var/www/html;地点/{index index.php index.html index.htm;}位置^~/博客{proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header 主机 $http_host;proxy_set_header X-Forwarded-Proto $scheme;proxy_pass http://127.0.0.1:2368;}位置 ~ \.php$ {fastcgi_pass unix:/var/run/php-fpm.sock;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;包括 fastcgi_params;}}

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

 位置/phpMyAdmin {别名/usr/share/phpMyAdmin/;try_files $uri $uri//index.php;位置 ~ ^/phpMyAdmin/(.+\.php)$ {别名/usr/share/phpMyAdmin;fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;fastcgi_param SCRIPT_FILENAME/usr/share/phpMyAdmin/$1;包括 fastcgi_params;fastcgi_intercept_errors 开启;允许XXX.XXX.XX.XX;#否认一切;#}}}

<块引用>

更新(我做了亲爱的qwsj回答,之后这是我的更新.)

我在/usr/share/phpMyAdmin 安装了 phpmyadmin

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

我打开 https://mywebisite/phpmyadmin/

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

解决方案

In error log upstream: "fastcgi://127.0.0.1:9000" 但在配置中你使用 unix socket (mb你不重新加载/重启?).

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

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

listen.owner = nginxlisten.group = nginx

Nginx 配置例如:

用户nginx;


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

[root ~]# sestatusSELinux 状态:已启用...

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

[root ~]# sestatusSELinux 状态:禁用[根~]#

在我的测试中配置:

 位置/phpMyAdmin {根目录/usr/share;index index.php index.html index.htm;位置 ~ ^/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;包括 fastcgi_params;fastcgi_intercept_errors 开启;}}

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

I'm studying centos7 and nginx. I can display index.html with cerbot SSL. And I installed phpmyAdmin then I open https://mywebsite.com/phpMyAdmin/ I got 502 Bad Gateway errir Could someone teach me right way please?

Here is my log.

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"

Here is my 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;
}
}

And here is my /etc/nginx/conf.d/default.conf server {

    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/$1;
            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.)

I installed phpmyadmin at /usr/share/phpMyAdmin

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

I open https://mywebisite/phpmyadmin/

error log says directory index of "/var/www/html/mywebisite/phpmyadmin/" is forbidden,

解决方案

In error log upstream: "fastcgi://127.0.0.1:9000" but in config you use unix socket (mb you dont make a reload/restart?).

Check the php-fpm config (variable listen), what is the real path to socket /var/run/php-fpm.sock or /var/run/php-fpm/php-fpm.sock?

Also, after this, check listen permission for php-fpm, the user must be identical to the user in nginx config (nginx.conf). PHP-FPM Pool config eg:

listen.owner = nginx
listen.group = nginx

Nginx config eg:

user nginx;


UPD: Please check SELinux status, need disabled it:

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

Update SELinix /etc/selinux/config from SELINUX=enforcing to SELINUX=disabled. After this, need reboot. After reboot:

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

Config on my test:

    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;
        }
    }

Dont make a symlink ln -s /usr/share/phpMyAdmin /var/www/html/mywebisite/phpmyadmin, its not needed

这篇关于phpMyAdmin 502 网关错误 [CentOS7, nginx]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆