Author Photo

Ahmer's SysAdmin Recipes is a blog for Linux System Administrators. This blog provides recipes for Installation & Configuration of Linux, Ubuntu, Oracle Database, MySQL, Apache, Nginx, Oracle Cloud Control, FreeIPA, Kerberos & OpenLDAP, Subversion, PXE, DevOps, etc. over Red Hat Enterprise Linux (RHEL), CentOS, Ubuntu and Windows.

Please give me your feedback and help me improve this blog. Please let me know If you want me to write on a specific topic.

Friday, 26 February 2016

Install phpMyAdmin on CentOS 7 LAMP Server

Install phpMyAdmin on CentOS 7 LAMP ServerphpMyAdmin is a free and open source tool written in PHP. phpMyAdmin is intended to handle the administration of MySQL or MariaDB through a Web UI (User Interface). Database Administrators uses phpMyAdmin to perform various tasks such as creating, modifying or deleting databases, tables, fields or rows; executing SQL statements; managing users and permissions; or monitoring database instances.

In this article, we will install phpMyAdmin on a CentOS 7 LAMP server.

 

System Specification:

In this article, we use the same CentOS 7 LAMP server, that we have configured in our previous post Install Linux, Apache, MySQL & PHP (LAMP) Stack).

Hostname lampserver.mydomain.com
IP Address 170.172.0.30/16
Operating System CentOS 7
Apache HTTP Server 2.4.6
MySQL Server 5.7
PHP 5.4

 

Install phpMyAdmin on CentOS 7 LAMP Server:

Browse to https://www.phpmyadmin.net/downloads/ to download a compatible version of phpMyAdmin according to your LAMP stack versions.

We have downloaded phpMyAdmin 4.4.15.4 according to our LAMP Stack versions. phpMyAdmin is available in various zip format and languages, you should select one according to your requirement.

[root@lampserver ~]# cd /soft [root@lampserver soft]# wget https://files.phpmyadmin.net/phpMyAdmin/4.4.15.4/phpMyAdmin-4.4.15.4-english.tar.gz

Extract the zip file and move the extracted directory to the Apache HTTP Server’s document root.

[root@lampserver soft]# tar -xvf phpMyAdmin-4.4.15.4-english.tar.gz [root@lampserver soft]# mv phpMyAdmin-4.4.15.4-english /var/www/html/phpmyadmin

Reapply the SELinux security context for the phpmyadmin directory.

[root@lampserver soft]# restorecon -Rv /var/www/html

phpMyAdmin requires following php modules to be installed. Therefore, install it as folllows:

[root@lampserver soft]# yum install -y php-mbstring [root@lampserver soft]# systemctl restart httpd.service

Connect to MySQL database server.

[root@lampserver soft]# mysql -u root –p

Create phpMyAdmin repository using create_tables.sql script, provided in phpMyAdmin zip file.

mysql> source /var/www/html/phpmyadmin/sql/create_tables.sql mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'localhost' IDENTIFIED BY 'Pma$1234'; mysql> quit

Although, phpMyAdmin can be run with zero configuration, but it is a good idea to configure some security related parameters. To create a config file for phpMyAdmin using setup script, execute following commands:

[root@lampserver soft]# mkdir /var/www/html/phpmyadmin/config [root@lampserver soft]# chmod o+rw /var/www/html/phpmyadmin/config [root@lampserver soft]# cp /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config/config.inc.php [root@lampserver soft]# chown -R apache:apache /var/www/html/

Create SELinux policy for the config directory to allow web server to write on it.

[root@lampserver soft]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/phpmyadmin/config(/.*)?" [root@lampserver soft]# restorecon -Rv /var/www/html [root@lampserver soft]# systemctl restart httpd.service

Browse to URL  http://170.172.0.30/phpmyadmin/setup/ to create a config file with custom settings and amend the settings according to your requirement.

You can see some examples of settings in the below screenshots.

phpMyAdmin-config-01phpMyAdmin-config-02phpMyAdmin-config-03

Once done, Save the settings, it will give you the advise to move the config.inc.php file to phpMyAdmin web root and remove the config file.

[root@lampserver soft]# mv /var/www/html/phpmyadmin/config/config.inc.php /var/www/html/phpmyadmin/ [root@lampserver soft]# rm -rf /var/www/html/phpmyadmin/config/

Browse to URL http://170.172.0.30/phpmyadmin/

phpMyAdmin-login-01 phpMyAdmin-dashboard-01

phpMyAdmin has been successfully installed on CentOS 7 LAMP server, we can now manage our MySQL databases from phpMyAdmin Web UI.

Install phpMyAdmin on CentOS 7 LAMP Server


YOU MIGHT ALSO LIKE:

2 comments:

  1. In some cases, you have to explicitly define the Storage Mappings for pmadb tables in config.inc.php file like

    $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
    $cfg['Servers'][$i]['relation'] = 'pma__relation';
    $cfg['Servers'][$i]['table_info'] = 'pma__table_info';
    $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
    $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
    $cfg['Servers'][$i]['column_info'] = 'pma__column_info';
    $cfg['Servers'][$i]['history'] = 'pma__history';
    $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
    $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
    $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
    $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
    $cfg['Servers'][$i]['recent'] = 'pma__recent';
    $cfg['Servers'][$i]['favorite']='pma__favorite';
    $cfg['Servers'][$i]['users']='pma__users';
    $cfg['Servers'][$i]['usergroups']='pma__usergroups';
    $cfg['Servers'][$i]['navigationhiding']='pma__navigationhiding';
    $cfg['Servers'][$i]['savedsearches']='pma__savedsearches';
    $cfg['Servers'][$i]['central_columns']='pma__central_columns';
    $cfg['Servers'][$i]['designer_settings']='pma__designer_settings';
    $cfg['Servers'][$i]['export_templates']='pma__export_templates';

    ReplyDelete
  2. Additionally change the user, password to controluser, controlpassword respectively to enable utilization of storage features for others users without having the privileges on the pmadb.

    $cfg['Servers'][$i]['controluser'] = 'pma';
    $cfg['Servers'][$i]['controlpass'] = '123';

    ReplyDelete