Page 1 of 2

[ TUTORIAL ] How to change the default /phpmyadmin alias url

Posted: Sun Jun 08, 2014 1:36 pm
by jonn
In this tutorial we will show you how to change the default location to access /phpmyadmin to something else more private.
Why would we do this, firstly it deters automated bots & also anyone who knows you may be using phpmyadmin on your server from finding the login page.

lets do this................

1) Connect to your server ROOT access (SSH)

2) Open the apache2.conf.

Code: Select all

nano /etc/phpmyadmin/apache2.conf
3) Find this line, should be at the top:

Code: Select all

Alias /phpmyadmin /usr/share/phpmyadmin
4) Change /phpmyadmin to anything!! for example we will use /private_phpmyadmin like this:

Code: Select all

Alias /private_phpmyadmin /usr/share/phpmyadmin
5) restart apache2, important!!

Code: Select all

/etc/init.d/apache2 restart
6) Let's go test it....
Type your old URL:

Code: Select all

http://change-to-your-server-ip-or-domain-setup/phpmyadmin

-- you should get a 404 error (page missing) Good!

Now Try the new private URL:

Code: Select all

http://change-to-your-server-ip-or-domain-setup/private_phpmyadmin 
That's it, now only you and your private clients will know where the login page for phpmyadmin is located.

This change will not update the link in vestacp to the phpmyadmin link under websites, you will need to change the url destination in the theme also.

THEME/UI EDIT Link

As requested, here is the way to edit the new link in the theme
We need to do this in two areas, admin and user folders.

1) Connect to your server ROOT access (SSH)

2) Open Admin Folder

Code: Select all

nano /usr/local/vesta/web/templates/admin/list_db.html
Find the line:

Code: Select all

if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpmyadmin/";
Change it to:

Code: Select all

if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/private_phpmyadmin/";
F2, Y, enter.

3) Open USER Folder

Code: Select all

nano /usr/local/vesta/web/templates/user/list_db.html
Find the line:

Code: Select all

if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpmyadmin/";
Change it to:

Code: Select all

if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/private_phpmyadmin/";
F2, Y, enter.

Test it, all good.

:)

Re: [ TUTORIAL ] How to change the default /phpmyadmin alias

Posted: Tue Jun 10, 2014 6:17 am
by erldcrtz
can you also post guide where we could edit the phpmyadmin link in the theme/UI ?

Re: [ TUTORIAL ] How to change the default /phpmyadmin alias

Posted: Tue Jun 10, 2014 8:53 am
by jonn
erldcrtz wrote:can you also post guide where we could edit the phpmyadmin link in the theme/UI ?
post updated.

Re: [ TUTORIAL ] How to change the default /phpmyadmin alias

Posted: Tue Jun 24, 2014 3:55 pm
by imperio
Hi, jonn
Thank you for your help

Re: [ TUTORIAL ] How to change the default /phpmyadmin alias

Posted: Thu Jun 26, 2014 11:37 am
by purwa
Hi Jonn,
on database creation there's a notification with link to phpmyadmin

Code: Select all

Adding database → Database admin_test has been created successfully / open phpMyAdmin
how to change this link?

Re: [ TUTORIAL ] How to change the default /phpmyadmin alias

Posted: Fri Dec 12, 2014 4:55 pm
by Tralapo
Nice tutorial, thanks for that. One thing: I tried it today on Ubuntu 14.04 LTS. File named in step 2) is named apache.conf now, not apache2.conf.

But when I look at the config and log file locations named in VestaCP Docs (http://vestacp.com/docs/#config-log-loc ... ian-ubuntu) they are wrong most of the time to. So maybe it's an Ubuntu thing then? Or the docs aren't up to date.

Re: [ TUTORIAL ] How to change the default /phpmyadmin alias url

Posted: Tue Jan 05, 2016 11:03 pm
by arafatx
cannot find apache2.conf in centOS. Can anyone point me where is the setting file. Edited: I found the right one here etc/httpd/conf.d/phpMyAdmin.conf

Re: [ TUTORIAL ] How to change the default /phpmyadmin alias url

Posted: Sat Mar 26, 2016 5:06 am
by WAS
I've edited both template files but Vesta CP still links to phpmyadmin folder, any ideas?

Re: [ TUTORIAL ] How to change the default /phpmyadmin alias url

Posted: Fri Nov 11, 2016 8:20 pm
by Naldinho
WAS wrote:I've edited both template files but Vesta CP still links to phpmyadmin folder, any ideas?
Late but might be useful for someone else

Code: Select all

$db_myadmin_link = "http://".$http_host."phpmyadmin/";
needs changing on both files.

Re: [ TUTORIAL ] How to change the default /phpmyadmin alias url

Posted: Sun May 14, 2017 5:31 am
by blueberry
Also, don't forget to update here:

sudo nano /usr/local/vesta/web/add/db/index.php

Look for:

if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpmyadmin/"