// Tutorial //

How To Install phpMyAdmin on a LEMP server

Published on July 27, 2012 · Updated on January 19, 2021
Default avatar
By Etel Sverdlov
Developer and author at DigitalOcean.
How To Install phpMyAdmin on a LEMP server

About phpMyAdmin

phpMyAdmin is a free software to work with MySQL on the web—it provides a convenient visual front end to the capabilities of MySQL.

Setup

Prior to installing phpMyAdmin, be sure that you have LEMP installed on your VPS. If you do not, you can see how to do that here.

Once you have finished installing LEMP on your virtual private server, you can start on installing phpMyAdmin.

Step One—Install phpMyAdmin

Start off by downloading the program from apt-get.

sudo apt-get install phpmyadmin

During the installation, phpmyadmin will ask you if you want to configure the database with dbconfig. Go ahead and choose yes.

Input MySQL’s database password when prompted and click ok.

When phpmyadmin prompts you to choose a server (either apache or lighttpd) hit tab, and select neither one.

Step Two—Configure phpMyAdmin

You now have phpMyAdmin installed on your server. In order to access it, you need to take one more step.

Create a symbolic link between phpMyAdmin and your site’s directory. If you were using the previous tutorial, it may be still located in the nginx default directory, otherwise link it with the appropriate place:

sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/www

Restart nginx:

sudo service nginx restart

You should now be able to access phpMyAdmin by going to yourdomain/phpmyadmin. The screen will look like this.

Log in with your MySQL username and password.

By Etel Sverdlov

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.

Sign up
About the authors
Default avatar
Developer and author at DigitalOcean.

Still looking for an answer?

Was this helpful?
10 Comments

I had to do: sudo ln -s /usr/share/phpmyadmin/ /var/www/html/

instead of sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/www

If you are gettting the 404 in yourdomain.com/phpmyadmin, try

sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html

and then

sudo service nginx restart

instead of

sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/www

(This is because the folder “www” was replaced in the newer versions of Nginx through “html”).

For those who changed root folder and want to access domain.com/phpmyadmin.

Step 1: sudo nano /etc/nginx/sites-available/example.com Step 2: Add below line

location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+.php)$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location ~* ^/phpmyadmin/(.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } }

Save and exit Step 3: sudo service nginx restart

DONE!!

If you were following the tutorial here: https://www.digitalocean.com/community/articles/how-to-install-wordpress-with-nginx-on-ubuntu-12-04 your wordpress website is in /var/www so instead of

sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/www

use

sudo ln -s /usr/share/phpmyadmin/ /var/www

I followed all the steps but when i try to access phpmyadmin it doesn,t show up. What i get is my wordpress home page.

http://192.81.215.199/phpmyadmin/ = http://192.81.215.199

Any idea?

Thank you.

I followed all the steps but still getting error: 404 Not Found nginx/1.18.0 (Ubuntu)

In step two, since the home directory for NGINX is at /var/www/html/phpmyadmin, that simlink command should be: sudo ln -s /usr/share/phpmyadmin/ /var/www/html/phpmyadmin

Use this is you follow the tutorial and get a 404 error when you try to access phpmyadmin in your browser.

Cheers, Somto

Hey,

I’m getting a 404 error after using this guide. I have multiple domain set up on Ubuntu using nginx. The only difference was the following command:

sudo ln -s /usr/share/phpmyadmin/ /var/www

There is a phpmyadmin directory within /var/www/. Do I need to add server block possibly? Since I have multiple domains, each of them has a separate configuration file.

Any suggestions?

getting blank screen when going to mydomain.com/phpmyadmin with these errors in browser’s console:

Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
Uncaught ReferenceError: $ is not defined
Uncaught ReferenceError: PMA_commonParams is not defined

On newer version of Ubuntu the root might be “/usr/share/nginx/html” :

sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html

Restart nginx:

sudo service nginx restart