无法在Nginx服务器上访问phpMyAdmin

时间:2018-08-06 15:36:36

标签: ubuntu nginx phpmyadmin

我刚刚在Nginx服务器上安装了phpMyAdmin,但是当我转到https://example.com/phpmyadmin时,没有任何加载,我只看到主网站。

我尝试将以下代码添加到Nginx默认文件中,但随后收到502 Bad Gateway

# Phpmyadmin Configurations
location /phpmyadmin {
   root /usr/share/;
   index index.php index.html index.htm;
   location ~ ^/phpmyadmin/(.+\.php)$ {
           try_files $uri =404;
           root /usr/share/;
           #fastcgi_pass 127.0.0.1:9000;
           #fastcgi_param HTTPS on; # <-- add this line
           fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
           fastcgi_index index.php;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include fastcgi_params;
   }
   location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
           root /usr/share/;
   }
}

# Dealing with the uppercased letters
location /phpMyAdmin {
    rewrite ^/* /phpmyadmin last;
}

我尝试取消对fastcgi_param HTTPS on;的注释,因为我的站点正在使用HTTPS,但是我仍然收到502 Bad Gateway。我在这里错过了一步吗?如何允许Nginx正确显示phpMyAdmin?

谢谢!

1 个答案:

答案 0 :(得分:1)

1)您是否尝试测试nginx配置,其中可能有一些错误? 通过执行

$ sudo nginx -t

此命令用于在nginx.conf上运行语法检查和测试。

正确的输出应类似于:

nginx -t的输出 nginx:配置文件/etc/nginx/nginx.conf语法正常 nginx:配置文件/etc/nginx/nginx.conf测试成功。

2)可能性很多,但如果您选择使用FPM,则很可能是指向错误的版本。

fastcgi_pass Unix:/var/run/php/php-fpm.sock;

相关问题