Install phpMyAdmin on Digital Ocean Droplet for Nginx, Laravel


Install phpMyAdmin on Digital Ocean Server for Laravel,Nginx

phpMyAdmin is a opensource software tool written in PHP, intended to handle the administration of MySQL database over the Web. It supports a wide range of operations on MySQL and MariaDB. Frequently used operations such as managing databases, tables, columns, relations, indexes, users, permissions, etc. can be performed via the user friendly graphical interfaces, while you still have the ability to directly execute any SQL statement.

Prerequisites

  1. You should have already setup LEMP Server Stack on Your Digital Ocean Droplet.
  2. Login to your terminal with a not-root user with sudo privileged, if you haven't one, Click here to create a Less privilegedsudo user in your server.

Let's begin by updating our local package index so that we have access to the most recent package listings:

sudo apt-get update

Step1: Install phpMyAdmin on Digital Ocean Droplet for Laravel along with LEMP Server stack

sudo apt install phpmyadmin

When type the above command in your terminal, and it will begin to start download and install the phpMyAdmin, when it prompts to continue ? Press y and ENTER. During the installation process, you will be prompted with various configuration screens, Depending on your Server setup, the order of the configuration screen might be vary than mine.

Next you will be prompted to choose your web server like bellow: Nginx will most likely not be one of them, so that you have to skip by pressing TAB and then Enter to continue without selecting a Web Server.

Install phpMyAdmin on Digital Ocean Droplet for Laravel along with LEMP Server stack

in the next screen, it will prompt whether you want to install and configure the database for phpMyAdmin, here you must select Yes and then press ENTER.

configure the database for phpMyAdmin on Digital Ocean Droplet

Next, the MySQL application password is only used internally by phpMyAdmin to communicate with MySQL Server. You can leave this blank and a password will be generated automatically. Just press ENTER to continue.

Configure MYSQL application password for phpMyAdmin

And that’s it. Now we have installed the phpMyAdmin on the server successfully.


Step 2. Create Symbolic Link

In order for Nginx to serve the phpMyAdmin files correctly, we must create a symbolic link from the phpMyAdmin directory /usr/share/phpmyadmin to the Nginx document root directory.
The default location of the Nginx document root in Ubuntu 18.04 should be /var/www/html/, though it could be different depending on if you have modified the root path of default server block. Since we have installed Laravel Project on our server, document root may be located in somewhere like /var/www/projectname/public.
Once you have confirmed your document root, let’s create a symbolic link from the phpMyAdmin directory to the document root. Here I will assume your document root is /var/www/yourdefaultproject/public and we will simply add phpmyadmin to the end of it. This will allow us to access phpMyAdmin at http://yourdomainname.com/phpmyadmin or http://yourserverip/phpmyadmin, depending on if you use IP address or domain name in the server_name directive in your default server block.

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


Step3. Test phpMyAdmin

You should now be able to access the phpMyAdmin web interface by visiting your server’s domain name or public IP address followed by /phpmyadmin. e.g. http://example.com/phpmyadmin or http://youripaddress/phpmyadmin, if everything went correct, you should see the login page similar to the following:

Image title

You should have noted the root username and password when installing MySQL for the first time or if you have followed my other article on how to setup LEMP Server Stack on Digital Ocean Droplet for Laravel . However, remote login might be disabled for root. If you get an error  “Access denied for user ‘root’@’localhost'”, you should continue to Step 4 to create a new database user and grant full privileges to access and manage all database.


Step 4: Create MySQL User

Let's login to MySQL CLI with root user:

sudo mysql -u root -p

it might prompt for root password depending on if you have given a password or left it empty when you setup MySQL first time, when prompt for password, either enter the password or just press ENTER to continue if you didn't setup one:

Next run the following command in your terminal, make sure to replace the testuser and testpassword with your own.

CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'testpassword';

Then we will grant the new user with full privilege to access all database on the server:

GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'localhost' WITH GRANT OPTION;

Next we should flush and rebuilt the privilege:

FLUSH PRIVILEGES;

and if you want to create a database, run the following command with replacing the testdb with your own name: 

CREATE DATABASE testdb;

You should now be able to access phpMyAdmin using this new user account, if everything went well, you should also see the sample database you just created.


Step 5: Obscure phpMyAdmin URL

Internet Bots and those bad guys who called them selves as hacker are continuously scanning web servers for phpMyAdmin, it is easy to find phpMyAdmin login page since the standard URL scheme for phpMyAdmin login page is something like this http://example.com/phpmyadmin

It is possible to rename /phpmyadmin to /somethingelse , if you can remember In step 2, we created a symbolic link in the document root /var/www/yourdefaultproject/public/phpmyadmin , we need to rename this symbolic link to something else, like ex: /titanicdb , Let's do it:

sudo mv /var/www/yourdefaultproject/public/phpmyadmin /var/www/yourdefaultproject/public/titanicdb

That is it, You should now be able to access phpMyAdmin at http://example.com/titanicdb. You can rename it to any words as you prefer.

    If you have any other questions, experience or insights on "How to Install phpMyAdmin on Digital Ocean Droplet" please feel free to leave your thoughts in the comments bellow, Don't forget to share the posts.
Written by Akram Wahid 2 months ago

are you looking for a chief cook who can well craft laravel and vuejs, to make some awsome butterscotch,
yes then it is right time for you to look at my profile.

Do you want to write Response or Comment?

You must be a member of techalyst to proceed!

Continue with your Email ? Sign up / log in

Responses

Be the first one to write a response :(

{{ item.member.name }} - {{ item.created_at_human_readable }}

{{ reply.member.name }} - {{ reply.created_at_human_readable }}