Matt
Matt

Reputation: 551

Can't Access phpMyAdmin on Nginx Server

I've just installed phpMyAdmin on my Nginx server but when I go to https://example.com/phpmyadmin, nothing loads, I only see the main website.

I tried adding the following code to the Nginx default file, but then I receive 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;
}

I've tried un-commenting fastcgi_param HTTPS on; as my site is using HTTPS but I still receive 502 Bad Gateway. Am I missing a step here? How do I allow Nginx to show phpMyAdmin correctly?

Thank you!

Upvotes: 1

Views: 2948

Answers (1)

Vishal Kute
Vishal Kute

Reputation: 102

1)Did you tried to test your nginx configuration, there could be some errors in it? It is done by executing

$ sudo nginx -t

This command is used to run syntax check and tests on your nginx.conf.

Correct output should be something like:

Output of nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful.

2) Lots of possibilities but if you opted to use FPM most probably you are pointing to the wrong version.

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

Upvotes: 1

Related Questions