Consider a domain “example.com” hosted on server 172.xxx.xxx.31 with the document root /var/www/example.com/public_html/ and a MySQL server on another server with IP 80.xxx.xxx.123. There are various options for remotely accessing the MySQL server via a web browser. Let’s look at how it can be done with phpMyAdmin.
First, we will create a sub directory phpMyAdmin inside the doc root of the domain example.com.
#mkdir /var/www/example.com/public_html/phpmyadmin
Change the current directory to phpMyAdmin
#cd /var/www/example.com/public_html/phpmyadmin
Download the latest version of phpMyAdmin from the official website and extract it into the document root directory
#wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip
#unzip phpMyAdmin-5.2.1-all-languages.zip
#cd phpMyAdmin-5.2.1-all-languages
Now, move all of the files in the directory to the doc root of phpMyAdmin, which is ;
/var/www/example.com/public_html/phpMyAdmin.
#mv * /var/www/example.com/public_html/phpmyadmin
Remove the zip file using:
#rm phpMyAdmin-5.2.1-all-languages.zip
Set appropriate permissions for the phpMyAdmin directory
#chown -R apache:apache /var/www/example.com/public_html/phpmyadmin
There is no need to modify the apache configuration file because it was already used for the old domain. If you want to make any changes, you can do them in:
#vim /etc/httpd/conf.d/example.com
After making any changes in the apache conf file, always remember to test and restart the service to apply the changes made
#apachectl -t
#systemctl restart httpd
Now go to the modify the phpMyAdmin configuration file,
#cp/var/www/example.com/public_html/phpmyadmin/config.sample.inc.php /var/www/example.com/public_html/phpmyadmin/config.inc.php
#vim /var/www/example.com/public_html/phpmyadmin/config.inc.php
And in the configuration file, find the line:
$cfg['Servers'][$i]['host'] = 'localhost';
And modify it as:
$cfg['Servers'][$i]['host'] = 80.xxx.xxx.123'';
After making any changes in the apache conf file, always remember to test and restart the service to apply the changes made
#apachectl -t
#systemctl restart httpd
Now go to the modify the phpMyAdmin configuration file,
#cp/var/www/example.com/public_html/phpmyadmin/config.sample.inc.php /var/www/example.com/public_html/phpmyadmin/config.inc.php
#vim /var/www/example.com/public_html/phpmyadmin/config.inc.php
And in the configuration file, find the line:
$cfg['Servers'][$i]['host'] = 'localhost';
And modify it as:
$cfg['Servers'][$i]['host'] = 80.xxx.xxx.123'';
After making the changes, save and exit. Now, we can access the MySQL server through your web by using the below URL:
“http://example.com/phpmyadmin”
Our Support Team is available to help if you encounter any issues or errors.