简体   繁体   中英

phpmyadmin 404 error in nginx

I've installed phpmyadmin via ppa in my Ubuntu machine ,but when try to access localhost/phpmyadmin i got 404 error

server is nginx

location /phpmyadmin{
            index index.php;
            root /usr/share/phpmyadmin/;
          }   
     location ~ \.php$ {
    include snippets/fastcgi-php.conf;

     fastcgi_pass unix:/run/php/php7.0-fpm.sock;
         #fastcgi_index index.php;
         include fastcgi_params;
}

Found so many questions related to this issue but nothing solved my problem

The symlink created in that guide points to /usr/share/nginx/www while your root directive points to another directory. Unless you specify another location block, NGINX doesn't technically know that the directory exists, and doesn't know where to route the incoming request.

First, remove the symlink you just created by running:

rm -rf /usr/share/nginx/www

That won't delete phpMyAdmin, it'll just delete the symlink. Now we'll create a new one using:

sudo ln -s /usr/share/phpmyadmin/ /var/www/html/phpmyadmin

Since you've set root to /var/www/html , that's your "home" directory or root path that your server block uses. What the above command does is create a symlink from where the phpMyAdmin files are to your root directory.

Once the new symlink is there, you should be able confirm that by running:

ls -al /var/www/html

That should produce something that looks like:

lrwxrwxrwx 1 root root   22 Apr  4 14:31 phpmyadmin -> /usr/share/phpmyadmin/

Which means the symlink is valid and should now work when you visit:

http://IP_ADDR/phpmyadmin

Where IP_ADDR is your IP address.

Your root is not correctly configured.

root sets the path BEFORE adding the location.

<root> + <location>

location /phpmyadmin{
        index index.php;
        root /usr/share/phpmyadmin/;
      }

This leads to /usr/share/phpmyadmin/phpmyadmin/

What you want is:

location /phpmyadmin{
        index index.php;
        root /usr/share/;
      }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM