In our previous article, we learned how to install LAMP Stack on a fresh Debian 9 server. To manage the database, the terminal or the command-line can be a pain for any reason. One of them is being a newbie. If you’re new to Linux, it’ll surely be quite struggling for you to learn. To do a fresh start, we’ll need phpMyAdmin. In this article, we’re going to learn how to install phpMyAdmin on a fresh Debian 9 machine.
What Is phpMyAdmin?
“phpMyAdmin is a free and open-source administration tool for MySQL and MariaDB. As a portable web application written primarily in PHP, it has become one of the most popular MySQL administration tools, especially for web hosting services.”, says Wikipedia about PMA.
Before beginning to install, we’ll need to make sure that we meet all the requirements.
- To have LAMP Stack installed
- Minimum 512mb of VPS – no less.
- Sudo/root privileges
Step 1 – Updating & Upgrading existing packages
As we always do, we’ll need to make sure that all packages and source files are updated and upgraded so that we don’t have any difficulties while installing. We’ll also need to install sudo. To do so, use the below-mentioned command.
apt install sudo
Done installing sudo. It’s time to update and upgrade the packages.
sudo apt update && apt upgrade
Press “Y” and then enter wherever asked.
Step 2 – Installing phpMyAdmin On Debian 9
We now have updated and upgraded the packages. Let’s install phpMyAdmin. To do so, paste the below-mentioned command to begin installing.
sudo apt install phpmyadmin
While installing phpMyAdmin, you will see a few prompts. The one would be a selection between apache2 and lighttpd.
You don’t need to brainstorm, just press enter for apache2. Now it will ask if you want to configure phpMyAdmin, of course yes! Then enter a secure password for the phpMyAdmin database and confirm it. It will ask for the root password. Enter the root password for MySQL you’ve set while installing the LAMP stack.
Press enter and then go for the password. Now when the progress bar reaches 100%, it means we’ve successfully installed phpMyAdmin on our server.
Step 3 – Creating A Separate MySQL Admin User
By default in a Debian system, the MySQL authentication username is set to root by default. Instead, we’ll use a separate MySQL user and grant them the administrative access. To do so, we’ll need to access the MySQL terminal. Use the below-mentioned command.
Now the command line for MySQL will be accessible.
Now enter the query.
CREATE USER 'pmadmin'@'localhost' IDENTIFIED BY 'super-siyar-wtd-i-hate-it-anime-jk-pw';
Replace ‘super-siyar-wtd-i-hate-it-anime-jk-pw‘ with the desired password where ‘pmadmin’ is the username. Time to give it privileges it deserves.
GRANT ALL PRIVILEGES ON *.* TO 'pmadmin'@'localhost' WITH GRANT OPTION;
Where ‘pmadmin’ will be the username you used to create. When done, type the following to get done with the settings.
Now, we’re done with almost everything. If you restart the apache2 and assume that the PHPMyAdmin would start working, then I’m sorry, It’ll show you 404.
You would have to create a symlink and then enable PHPMyAdmin and THEN restart apache. To do so, we’ll sort everything out in a single stroke.
ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf a2enconf phpmyadmin service apache2 restart
Now access the PMA by using your ip/phpmyadmin. If confusing, then copy paste and replace “IP.ADDR” with your server’s IP.
And it should now be accessible.
Now, doing all these things might be hectic for newbies. If you’re here, you’re probably a newbie too. You might also be looking for an affordable and secure solution for your setup. Best recommendation? Shadow Hosting. We provide you a secure and redundant server. You should probably check out our tweet showing how we were online for more than 333 days without a restart and still going super without any compromise. Isn’t that’s the type of solution you’re looking for? Checkout affordable and secure VPS Hosting solution at Shadow Hosting.