Installing PhpMyAdmin on Ubuntu 16.04 LEMP

October 6, 2017 3.8k views
LEMP Ubuntu 16.04

I'm trying to install phpMyAdmin by SSH on Ubuntu 16.04 with LEMP..
I'm stopped on this string:

sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/html

They take to me this error:

ln: failed to create symbolic link '/usr/share/ngix/html': No such file or directory

I've watched by FTP and the folders exist..!
Why take to me this error?

1 Answer

Solved adding this on nginx configuration:

location /phpmyadmin {
  root /usr/share/;
  index index.php;
  try_files $uri $uri/ =404;

  location ~ ^/phpmyadmin/(doc|sql|setup)/ {
    deny all;

  location ~ /phpmyadmin/(.+\.php)$ {
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    include snippets/fastcgi-php.conf;
  • Thanks so much for posting your solution! I could not get phpmyadmin to load. I made the change as you did and now it works.

    One note: The author said he added the above code to “nginx configuration”. To clarify, that would be the website config file for the website, which resides in etc/nginx/sites-available. In my case, the file name is “default” since I only run one site on the server and it resides in the webserver root.

    The “nginx configuration” file actually resides in etc/nginx and is named ”nginx.conf”. You would not put the above code in that. Include it instead in the config file for the site. In the case of multiple sites, add it to the config file of each site. This way you can control whether you want phpmyadmin available for a site or not. On sites where you don’t want it available, simply don’t add the code to the site config file.

Have another answer? Share your knowledge.