Added on May 29th, 2012 and marked as install mysql phpmyadmin

To install phpMyAdmin:

apt-get install phpmyadmin

You will be asked to choose the web server to be automatically configured by the install process. Since the only choices are apache2 and lighttpd we want to skip this section without selecting any web server: Tab + Enter.

Choose to configure the phpmyadmin database with dbconfig-common (skip it only if you know what you are doing).

The database’s root user should have a password. If no password was specified during the installation of MySQL you can set it using this command:

mysqladmin -u root password NEWPASSWORD

Add the following code to the nginx configuration file of the site where you want to use phpMyAdmin

server {
    ...

    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_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include /etc/nginx/fastcgi_params;
        }

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

    location /pma {
        rewrite ^/* /phpmyadmin last;
    }

    ...
}

Security

To disable remote access, except from certain allowed (trusted) IP-addresses, add the following lines to the relevant location block:

location /phpmyadmin {
    ...
    allow   {ALLOWED-IP};
    allow   {ANOTHER-ALLOWED-IP};
    deny    all;
    ...
}

Read more about the HttpAccessModule on the nginx wiki.

Errors using phpMyAdmin

Missing mcrypt extension

When you see an error message like this:

The mcrypt extension is missing. Please check your PHP configuration.

It means you should install the mcrypt extension.

From the phpMyAdmin requirements page:

When using the “cookie” authentication method, the mcrypt extension is strongly suggested for most users and is required for 64–bit machines. Not using mcrypt will cause phpMyAdmin to load pages significantly slower.

So, lets install it and restart php5-fpm:

apt-get install php5-mcrypt
service php5-fpm restart

Server running with Suhosin

Suhosin is used to protect servers and users from known and unknown flaws in PHP applications and the PHP core. In combination with phpMyAdmin however, it can have impact on the performace of PMA.

Check the phpMyAdmin documentation for some details on how to get them to work together.

Background information