When you install phpMyAdmin in your machine and then put that machine in production or beta mode, you would have /PHPMyAdmin directory and never want non-authorized users snooping around your phpMyAdmin. In this case, disabling phpMyAdmin can be time-consuming. So what if we’re able to change the entire directory itself? So hang tight. In this article, we’re going to learn how to change your phpMyAdmin directory in your CentOS 7 machine.
Since we’re changing the directory here, we’d assume that we already have installed PHPMyAdmin in the machine. If not, you can check the article on how to install PHPMyAdmin in CentOS 7 machine.
Getting Started with Changing PHPMyAdmin Directory
Let’s get started. The most basic thing is obviously, connecting to the VPS. You can do it by using the SSH Client called Putty. It will help you to connect to your VPS/server. You can also check the article on how to connect to a VPS using putty.
Step 1 – Fixing 403 Forbidden Error
In a fresh installation of PHPMyAdmin, you’re likely to face a “403 Forbidden Error”. But there is nothing to worry about. You can check our article on how to fix the 403 Forbidden error.
Step 2 – The Right Directory & Text Editor
The right directory for PHPMyAdmin.conf by default in /etc/httpd/conf.d. Let’s head there.
cd /etc/httpd/conf.d yum install nano -y
The reason why I included the installation of nano is that it doesn’t come by default in many versions of CentOS packages offered by hosting providers.
Step 3 – Changing Few Lines
Changing the director for PHPMyAdmin is super easy. All you have to do is change this from that. Let’s first open the file.
Now find these lines:
Alias /phpMyAdmin /usr/share/phpMyAdmin Alias /phpmyadmin /usr/share/phpMyAdmin
…and change them to:
#Alias /phpMyAdmin /usr/share/phpMyAdmin #Alias /phpmyadmin /usr/share/phpMyAdmin
..by adding “#” or symbolic “hash” to comment on those lines. Now add this line just after those commented lines.
Alias /thisismyphpmyadmin /usr/share/phpMyAdmin
…Where “/thisismyphpmyadmin” is the new directory. Save it by pressing CTRL + X and then press “Y” and then “Enter” key. It means, “/phpmyadmin” will now show 404 error and “/thisismyphpmyadmin” will open the PHPMyAdmin interface. Alternatively, you can add more of those lines after the new line and allow PHPMyAdmin to open at whatever address you want.
Step 4 – Finalizing & Restarting
But for it to be in effect, you have to restart the Apache. To do so, type the following command.
service httpd restart
After this, go to your browser and open “http://youserverip/thisismyphpmyadmin”. It will show up the PHPMyAdmin interface.
New to VPS and Linux? Want to learn new Linux computing and stuff? Get yourself a VPS and start making and breaking things. Totally affordable and best for both the learning and production environment. Assuming you’re new to Linux computing, we recommend you to buy Screwdriver Plan(The first one with 4 GB RAM). Open up, break it, fix it, add stuff in it and that’s how you learn with your screwdriver! Get yourself an affordable VPS Hosting with Shadow Hosting.
Also, make sure you’re well equipped with our developer’s hub consisting of multiple tools for pen-testers and developers at ShadowCrypt. You can find multiple technical and hacking tools. Give it a try! It’s for free and does not require you to be a Shadow Hosting’s customer and can work without registration.