Get phpMyAdmin to work with Nginx

To get phpmyadmin to work with Nginx, here are the things need to add into /etc/nginx/sites-available/default

One thing to take note, the root suppose to be /usr/share but not directly /usr/share/phpmyadmin.

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

location ~ \.php$ {
     set $php_root   $document_root;
         if ($request_uri ~* /phpmyadmin) {
             set $php_root /usr/share;

     fastcgi_index index.php;
     fastcgi_param  SCRIPT_FILENAME  $php_root$fastcgi_script_name;
     include /etc/nginx/fastcgi_params;

As for the location to handle php file. Here is an explanation why the directive will get error