4

I just installed LEMP stack but my phpmyadmin is acting weird every time I log in. After login, I always get error 404.

This is the URL after logging in (NOTE the user is now logged in):

http://localhost/index.php?token=c47a44d4fefaa8ef326d507c26fe9541&phpMyAdmin=207bvrfpmrj3r50769qpvjc6m2jrr2mq

and I get error 404.

When I type localhost/phpmyadmin, it now works normally.

  • Check the nginx error logs to see what path it's trying to reach on the server and compare to known paths? – Thomas Ward Nov 11 '16 at 16:17
  • were is the error logs located for nginx? I'm not familiar with it only in apache – Skeeith22 Nov 11 '16 at 18:09
  • This has nothing to do with installing, it's something you get when trying to log in. – Rafael Jul 20 '17 at 11:23
11

This is a : no need to think setup for Ubuntu 16.04 with php7-fpm already installed.

sudo apt-get install phpmyadmin

Then copy paste just before the last } of the file the following block into /etc/nginx/sites-avaliable/default

    location /phpmyadmin {
        root /usr/share/;
        index index.php index.html index.htm;
        location ~ ^/phpmyadmin/(.+\.php)$ {
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        }
        location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
            root /usr/share/;
        }
    }

Save and restart nginx with :

sudo service nginx restart
  • please note : you may note be able to login with root user. Use phpmyadmin user with password to be found in /etc/dbconfig-common/phpmyadmin.conf – jmary Jan 5 '17 at 6:35
  • NB: Line number 8 in your answer should read: " fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; " - the $ is missing from document_root. This helped resolve the problem for me. – Grant Apr 11 '17 at 15:25
  • 1
    Thanks ... it's strange, because I copied from my own config file, and it has the $ indeed. I edited the code to add the $ – jmary Apr 13 '17 at 7:21
  • The line "fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;" can be adapted according to your php running version ... Visit /var/run to figure it out. – jmary Nov 6 '18 at 15:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.