Getting started with Linux: Installing phpMyAdmin on CentOS
Problem: I am running a MySQL/MariaDB service on CentOS, and I want to use phpMyAdmin to manage databases through network interfaces. What is the best method for installing phpMyAdmin on CentOS?
PhpMyAdmin is a Web-based MySQL/MariaDB database management tool based on PHP. Although some lightweight database management tools such as Adminer already exist, phpMyAdmin is more widely used in website administrators to manage various MySQL/MariaDB tasks. It supports almost all MySQL database/table related operations, such as browsing, creating, copying, deleting, renaming, and changing, as well as MySQL user/permission management and database import/export. The following describes how to install phpMyAdmin on CentOS 6 or 7.
Prerequisites
To install phpMyAdmin on CentOS, set up a Web server (such as Apache or nginx) and install MySQL/MariaDB and PHP. Depending on your preferences and needs, you can select an installation from LAMP and LEMP.
Install and configure LAMP in CentOS 6.5
Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04
Compile and install LAMP in CentOS 5.9 (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12)
Source code for Web server architecture in RedHat 5.4 build the LAMP environment and application PHPWind
Build a WEB Server Linux + Apache + MySQL + PHP in the LAMP source code Environment
Ubuntu-based LAMP optimization and Reinforcement
Another requirement is to allow the EPEL library to be installed on your CentOS. If you have not set it, click here.
Install phpMyAdmin on CentOS6 or 7
Once you have set the EPEL library, you can easily use the following command to install phpMyAdmin.
On CentOS 7:
- $ Sudo yum install phpmyadmin
On CentOS 7:
- $ Sudo yum install phpmyadmin php-mcrypt
Configure phpMyAdmin on CentOS 7
By default, phpMyAdmin on CentOS 7 can only be accessed from the loop address (127.0.0.1. To be able to connect remotely, You need to modify its configuration.
Open the phpMyAdmin configuration file (Path:/etc/httpd/conf. d/phpMyAdmin. conf) in the text editor, and find and comment out the code lines with the words "Require ip XXXX. There will be four such lines of code, replaced by "Require all granted. The modified configuration file is as follows.
- $ Sudo vi/etc/httpd/conf. d/phpMyAdmin. conf
- .....
- <Directory/usr/share/phpMyAdmin/>
- Adddefacharcharset UTF-8
-
- <IfModule mod_authz_core.c>
- # Apache 2.4
- <RequireAny>
- # Require ip 127.0.0.1
- # Require ip: 1
- Require all granted
- </RequireAny>
- </IfModule>
- <IfModule! Mod_authz_core.c>
- # Apache 2.2
- OrderDeny, Allow
- DenyfromAll
- Allowfrom127.0.0.1
- Allowfrom: 1
- </IfModule>
- </Directory>
-
- <Directory/usr/share/phpMyAdmin/setup/>
- <IfModule mod_authz_core.c>
- # Apache 2.4
- <RequireAny>
- # Require ip 127.0.0.1
- # Require ip: 1
- Require all granted
- </RequireAny>
- </IfModule>
- <IfModule! Mod_authz_core.c>
- # Apache 2.2
- OrderDeny, Allow
- DenyfromAll
- Allowfrom127.0.0.1
- Allowfrom: 1
- </IfModule>
- </Directory>
- .....
Finally, restart httpd to make the change take effect.
- $ Sudo systemctl restart httpd
Configure phpMyAdmin on CentOS 6
By default, phpMyAdmin on CentOS 6 prohibits access from each IP address. To be able to connect remotely, You need to modify its configuration.
Open the phpMyAdmin configuration file (Path:/etc/httpd/conf. d/phpMyAdmin. conf) in the text editor, and find and comment out the code line "Deny from all. Then, change the code line "Allow from 127.0.0.1" to "Allow from 0.0.0.0 ". The modified configuration file is as follows.
- $ Sudo vi/etc/httpd/conf. d/phpmyadmin. conf
- <Directory "/usr/share/phpmyadmin">
- Order Deny, Allow
- # Deny from all
- Allow from 0.0.0.0
- </Directory>
The next step is to encrypt the phpMyAdmin configuration file with the blowfish encryption tool. This step requires encryption of the password in the cookie as part of the cookie-based authentication.
Open the file shown in the following path in the text editor and use blowfish to set a random password, as shown below.
- $ Sudo vi/usr/share/phpmyadmin/config. inc. php
- $ Cfg ['blowfish _ secret '] = 'kd5g} d33aXDc50! ';/* You must fill in this for cookie auth! */
Finally, restart httpd to make the change take effect.
- $ Sudo service httpd restart
Test phpMyAdmin
Test whether phpMyAdmin is set successfully. Visit this page: http: // <web-server-ip-addresss>/phpmyadmin
You should be able to record any MySQL users (such as root) and manage MySQL/MariaDB databases/tables through the Web interface.
Troubleshooting
Here are some solutions to problems encountered when installing phpMyAdmin on CentOS.
When you try to connect to the phpMyAdmin page in the browser, you will see the "403 Forbidding" error:
You don't have permission to access/phpMyAdmin on this server.
This error occurs because phpMyAdmin blocks the remote connection from the IP address by default. To fix this problem, you need to edit its configuration file to allow remote connection. For more information, see.
When you connect to The phpMyAdmin page, you can see The information "The configuration file now needs a secret passphrase (blowfish_secret)." And you cannot log on.
To fix this problem, you need to edit the/usr/share/phpmyadmin/config. inc. php file to add a random blowfish password and restart httpd, as shown below.
- $ Cfg ['blowfish _ secret '] = 'kd5g} d33aXDc50! ';/* You must fill in this for cookie auth! */
- $ Sudo service httpd restart (CentOS6)
- $ Sudo systemctl restart httpd (CentOS7)
When you connect to the phpMyAdmin page, you will see the "Cannot load mcrypt extension. Please check your PHP configuration" error message.
To fix this problem, install the following package:
- $ Sudo yum install php-mcrypt
Restart httpd:
- $ Sudo service httpd restart (CentOS6)
- $ Sudo systemctl restart httpd (CentOS7)
Example of LAMP architecture collaborative application-phpMyAdmin
PhpMyAdmin and Wordpress for LAMP applications
PhpMyAdmin logon timeout Solution
Install phpMyAdmin and Adminer in Ubuntu
Implement SSL functions based on LAMP and install phpMyAdmin
Configure the LAMP + phpMyAdmin PHP (5.5.9) development environment in Ubuntu 14.04
PhpMyAdmin details: click here
PhpMyAdmin: click here