How To Securely Manage Secrets with HashiCorp Vault on Ubuntu 16.04


Whereas many customers want the performance of a database administration system like MySQL, its command-line interface could also be much less intuitive and consumer pleasant for some, presenting a barrier to entry.

phpMyAdmin was created in order that customers can work together with MySQL by an online interface. On this information, we’ll talk about learn how to set up and safe phpMyAdmin to be able to safely use it to handle your databases from an Ubuntu 16.04 system. We’ll construct this setup on high of the Nginx net server, which has a great efficiency profile and may deal with heavy masses higher than another net servers.


Earlier than you get began with this information, ensure you’ve accomplished the next prerequisite steps:

  • First, we’ll assume that you’re utilizing a non-root consumer with sudo privileges, as described in steps 1-Four of the preliminary server setup of Ubuntu 16.04.
  • We’re additionally going to imagine that you’ve got accomplished a LEMP (Linux, Nginx, MySQL and PHP) set up in your Ubuntu 16.04 server. If you have not executed this but, you possibly can observe the information on putting in a LEMP stack on Ubuntu 16.04. Be sure you word your MySQL database administrator password.

Lastly, there are essential safety issues to concentrate on when utilizing software program like phpMyAdmin: it communicates immediately together with your MySQL set up, handles authentication utilizing MySQL credentials, and executes and returns outcomes for arbitrary SQL queries.

For these causes, and since it’s a widely-deployed PHP software that’s often focused for assault, you must by no means run phpMyAdmin on distant techniques over a plain HTTP connection. For those who do not need an current area configured with an SSL/TLS certificates, you possibly can observe this information on securing Nginx with Let’s Encrypt on Ubuntu 16.04.

As soon as you’ve got accomplished these prerequisite steps, you are able to get began with this information.

Step 1 — Set up phpMyAdmin

With our LEMP platform already in place, we are able to start by putting in phpMyAdmin, which is accessible from Ubuntu’s default repositories.

First, we’ll replace the server’s native bundle index to ensure it has a contemporary set of references to out there packages. Then, we’ll use the apt packaging instruments to tug the software program down from the repositories and set up it on our system:

  • sudo apt-get replace
  • sudo apt-get set up phpmyadmin

Through the set up, you’ll be prompted for some info. It would ask you which ones net server you desire to the software program to mechanically configure. Since Nginx, the online server we’re utilizing, is not one of many out there choices, you possibly can simply hit TAB, after which ENTER to bypass this immediate.

The subsequent immediate will ask if you want dbconfig-common to configure a database for phpMyAdmin to make use of. Choose “Yes” to proceed. You may have to enter the database administrator password that you just configured in the course of the MySQL set up to permit these modifications.

You’ll now be requested to decide on and make sure a password for the phpMyAdmin software and its database (which can be created on this step). Select and make sure a safe password and make word of it.

The set up will now full. For the Nginx net server to search out and serve the phpMyAdmin information accurately, we’ll have to create a symbolic hyperlink from the set up information to our Nginx doc root listing:

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

Lastly, we have to allow the mcrypt PHP module, which phpMyAdmin depends on. This was put in with phpMyAdmin, so we’ll toggle it on and restart our PHP processor:

  • sudo phpenmod mcrypt
  • sudo systemctl restart php7.0-fpm

With that, our phpMyAdmin set up is now operational. To entry the interface, go to your server’s area title or public IP handle adopted by /phpmyadmin in your net browser:


phpMyAdmin login screen

To register, use a set of credentials for a sound MySQL consumer. For instance, the root consumer and MySQL administrative password is an efficient option to get began. It is best to then have the ability to entry the executive interface:

phpMyAdmin admin interface

Click on round to get accustomed to the interface.

Within the subsequent two sections, we’ll take steps to safe our new phpMyAdmin net console.

Step 2 — Change the Default phpMyAdmin URL

The phpMyAdmin set up ought to be utterly purposeful at this level. Nevertheless, by putting in an online interface, we have uncovered our MySQL database server to the surface world. Due to phpMyAdmin’s recognition, and the massive quantity of knowledge it might present entry to, installations like these are widespread targets for assaults.

On this part, we’ll “harden,” or lock down, our set up by altering the interface’s URL from /phpmyadmin to one thing non-standard to sidestep a number of the automated bot brute-force makes an attempt.

In an earlier step, we created a symbolic hyperlink from the phpMyAdmin listing to our doc root to ensure that our Nginx net server to search out and serve our phpMyAdmin information. To vary the URL for our phpMyAdmin interface, we’ll rename this symbolic hyperlink.

First, let’s navigate to the Nginx doc root listing to get a greater sense of the change we’ll make:

You’ll obtain the next output:


complete 4 -rw-r--r-- 1 root root 612 Apr 10 16:40 index.nginx-debian.html lrwxrwxrwx 1 root root 21 Apr 10 17:06 phpmyadmin -> /usr/share/phpmyadmin

The output exhibits that we've a symbolic hyperlink known as phpmyadmin on this listing. We are able to change this hyperlink title to no matter we might like. It will in flip change phpMyAdmin's entry URL, which may help obscure the endpoint from bots hardcoded to go looking widespread endpoint names (comparable to "phpmyadmin").

Select a reputation that obscures the aim of the endpoint. On this information, we'll title our endpoint /nothingtosee, however you must select an alternate title. To perform this, we'll simply rename the hyperlink:

  • sudo mv phpmyadmin nothingtosee
  • ls -l

After operating the above instructions, you’ll obtain this output:


complete 4 -rw-r--r-- 1 root root 612 Apr 10 16:40 index.nginx-debian.html lrwxrwxrwx 1 root root 21 Apr 10 17:06 nothingtosee -> /usr/share/phpmyadmin

Now, should you go to the previous URL, you will get a 404 error:


phpMyAdmin 404 error

Now, your phpMyAdmin interface can be out there on the new URL we simply configured:


phpMyAdmin login screen

We are able to now additional harden our phpMyAdmin set up by establishing an authentication gateway.

Step 3 — Set Up an Nginx Authentication Gateway

The subsequent characteristic we'll arrange is an authentication immediate {that a} consumer could be required to go earlier than ever seeing the phpMyAdmin login display. Most net servers, together with Nginx, present this functionality natively. We'll simply want to change our Nginx configuration file with the small print.

Earlier than we do that, we'll create a password file that may retailer the authentication credentials. Nginx requires that passwords be encrypted utilizing the crypt() perform. The OpenSSL suite, which ought to already be put in in your server, contains this performance.

To create an encrypted password, sort:

You'll be prompted to enter and make sure the password that you just want to use. The utility will then show an encrypted model of the password that may look one thing like this:



Copy this worth, as you will want to stick it into the authentication file we'll be creating.

Now, create an authentication file. We'll name this file pma_pass and place it within the Nginx configuration listing:

  • sudo nano /and so forth/nginx/pma_pass

On this file, you’ll specify the username you wish to use, adopted by a colon (:), adopted by the encrypted model of the password you obtained from the openssl passwd utility.

We're going to title our consumer sammy, however you must select a special username. The file ought to appear like this:

/and so forth/nginx/pma_pass


Save and shut the file while you're executed.

Now, we're prepared to change our Nginx configuration file. Open it in your textual content editor to get began:

  • sudo nano /and so forth/nginx/sites-available/default

Inside this file, we have to add a brand new location part. It will goal the location we selected for our phpMyAdmin interface (we chosen /nothingtosee on this information).

Create this part inside the server block, however outdoors of some other blocks. We'll put our new location block beneath the / block in our instance:

/and so forth/nginx/sites-available/default

server {
    . . .

        location / {
                # First try to serve request as file, then
                # as listing, then fall again to displaying a 404.
                try_files $uri $uri/ =404;

        location /nothingtosee {

    . . .

Inside this block, we have to set the worth of a variable known as auth_basic to an authentication message that our immediate will show to customers. We do not need to point out to unauthenticated customers what we're defending, so do not give particular particulars. We'll simply use "Admin Login" in our instance.

We then want so as to add a variable known as auth_basic_user_file to level our net server to the authentication file that we simply created. Nginx will immediate the consumer for authentication particulars and examine that the inputted values match what it finds within the specified file.

After we're completed, the file ought to appear like this:

/and so forth/nginx/sites-available/default

server {
    . . .

    location / {
        try_files $uri $uri/ =404;

    location /nothingtosee {
        auth_basic "Admin Login";
        auth_basic_user_file /and so forth/nginx/pma_pass;

    . . .

Save and shut the file while you're executed.

To activate our new authentication gate, we should restart the online server:

  • sudo service nginx restart

Now, should you go to the phpMyAdmin URL in your net browser (if refreshing the web page doesn't work, you will have to clear your cache or use a special browser session should you've already been utilizing phpMyAdmin), try to be prompted for the username and password you added to the pma_pass file:


Nginx authentication page

When you enter your credentials, you will be taken to the usual phpMyAdmin login web page.

Along with offering an additional layer of safety, this gateway will assist maintain your MySQL logs clear of spammy authentication makes an attempt.


After finishing this tutorial, now you can handle your MySQL databases from a fairly safe net interface. This consumer interface exposes many of the performance out there through the MySQL command line. You'll be able to browse databases and schema, execute queries, and create new information units and buildings.

10 Free Breadcrumb CSS Snippets For Web Tasks

Previous article

New Boosted Boards have extra reasonably priced shortboard and higher batteries

Next article

You may also like


Leave a Reply

More in Linux