How do I set separate phpMyAdmin for each Nginx Server Blocks ?

October 19, 2014 1.4k views

Hello, I followed these tutorials:

How To Install Linux, nginx, MySQL, PHP (LEMP) stack on Ubuntu 14.04
How To Install and Secure phpMyAdmin with Nginx on an Ubuntu 14.04 Server
How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 14.04 LTS

After I removed the /etc/nginx/sites-enabled/default the /phpMyAdmin URI returned a 404 error on each and every virtualhost. I figured out I had to make a symlink to phpMyAdmin in every virtualhost like this cd /var/www/example.com/html && sudo ln -s /usr/share/phpmyadmin phpmyadmin.

Now its working fine, the problem is all virtualhost uses the same phpMyAdmin. I am planning to create a separate virtualhost for my friend to practice, but i don't want him to be able to modify my databases.

I hope there is an universal solution for this, because at some virtualhost I want to enable mongoDB and nodeJS at some I want to use PHP.

1 Answer

In phpMyadmin, you can create different users, and then give those users privileges on certain databases.

When someone logs in with a user, they will only see the databases they have privileges for.

Your main admin user, of course, will have Global Privileges that include Grant. Everyone else will be limited to the databases they need access to.

The one exception (for my little routine) is, in addition to an admin user, I also create a backup_user who has limited Global privileges. That way I can run a script on a daily schedule that backs up all databases.

Have another answer? Share your knowledge.