How do I install phpMyAdmin with Nginx?

7.19K viewsDatabasesFAQ Installation Intermediate MySQL PHP

I’m trying to install phpMyAdmin on Ubuntu with Nginx, but apt-get only shows Lighttpd and Apache2. What do I need to do to install phpMyAdmin LEMP?


this is really cool !


Assuming MySQL or MariaDB are installed, setting up phpMyAdmin is quite easy.

sudo apt-get install phpmyadmin

You’ll be asked if you’d like to configure the database and will be prompted to enter your a password. When you’re ask to choose between Apache and Lighttpd, just hit tab to select neither and continue with the installation.

phpMyAdmin gets installed in /usr/share/phpmyadmin. You can either create a symbolic link to phpMyAdmin from your Nginx document root, or you can add a location block to your site’s configuration to alias the phpmyadmin directory.

location /notphpmyadmin {
  alias /usr/share/phpmyadmin;
  location ~ \.php$ {
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass php;

You’ll probably want to use a name other than phpmyadmin to avoid hard-coded bots. It would also be a good idea to password protect the directory and make it only accessible via HTTPS.


Do i need to rename the phpmyadmin to something else before making the symbolic link?

You can create the link with whatever name you want as long as you link to the correct location. In fact, it’s a good idea to not use the default name for security.