Configure phpMyAdmin with Nginx

Posted on by Daniel


NERD ALERT: I must warn those of you who are not technical. This is full of nerdy and super-cool server admin information.

I’ve decided that I no longer want to have Apache on my servers. I have long since made the switch from Apache to Nginx, but never took the time to convert everyone of my sites, not to mention phpMyAdmin, which comes pre-configured to work with Apache (if you are using a Debian/Ubuntu server at least). At last I decided to take a crack at moving phpMyAdmin to Nginx and ditching Apache forever.

Finding a configuration was fairly simple, but I wanted to have a custom URL as a subdirectory of one of my current domains, all without moving the phpMyAdmin system files. Below is what I came up with:

location /secretdb {
  alias /usr/share/phpmyadmin/;
  try_files $uri $uri/ /index.php;
location ~ ^/secretdb(.+\.php)$ {
  alias /usr/share/phpmyadmin$1;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$1;
  include fastcgi_params;

As you can see, without switching any of my phpMyAdmin directories I was able to use the Nginx `alias` to allow access using a custom URL. I hope this helps someone else, because it took my awhile to get the configuration just right.


Category: Server Administration | Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>