Getting started with Linux: Installing phpMyAdmin on CentOS

Source: Internet
Author: User
Tags mcrypt

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:

  1. $ Sudo yum install phpmyadmin

On CentOS 7:

  1. $ 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.

  1. $ Sudo vi/etc/httpd/conf. d/phpMyAdmin. conf
  1. .....
  2. <Directory/usr/share/phpMyAdmin/>
  3. Adddefacharcharset UTF-8
  4.  
  5. <IfModule mod_authz_core.c>
  6. # Apache 2.4
  7. <RequireAny>
  8. # Require ip 127.0.0.1
  9. # Require ip: 1
  10. Require all granted
  11. </RequireAny>
  12. </IfModule>
  13. <IfModule! Mod_authz_core.c>
  14. # Apache 2.2
  15. OrderDeny, Allow
  16. DenyfromAll
  17. Allowfrom127.0.0.1
  18. Allowfrom: 1
  19. </IfModule>
  20. </Directory>
  21.  
  22. <Directory/usr/share/phpMyAdmin/setup/>
  23. <IfModule mod_authz_core.c>
  24. # Apache 2.4
  25. <RequireAny>
  26. # Require ip 127.0.0.1
  27. # Require ip: 1
  28. Require all granted
  29. </RequireAny>
  30. </IfModule>
  31. <IfModule! Mod_authz_core.c>
  32. # Apache 2.2
  33. OrderDeny, Allow
  34. DenyfromAll
  35. Allowfrom127.0.0.1
  36. Allowfrom: 1
  37. </IfModule>
  38. </Directory>
  39. .....

Finally, restart httpd to make the change take effect.

  1. $ 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.

  1. $ Sudo vi/etc/httpd/conf. d/phpmyadmin. conf
  1. <Directory "/usr/share/phpmyadmin">
  2. Order Deny, Allow
  3. # Deny from all
  4. Allow from 0.0.0.0
  5. </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.

  1. $ Sudo vi/usr/share/phpmyadmin/config. inc. php
  1. $ Cfg ['blowfish _ secret '] = 'kd5g} d33aXDc50! ';/* You must fill in this for cookie auth! */

Finally, restart httpd to make the change take effect.

  1. $ 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.

  1. 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.

  2. 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.

    1. $ Cfg ['blowfish _ secret '] = 'kd5g} d33aXDc50! ';/* You must fill in this for cookie auth! */
    1. $ Sudo service httpd restart (CentOS6)
    2. $ Sudo systemctl restart httpd (CentOS7)
  3. 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:

    1. $ Sudo yum install php-mcrypt

    Restart httpd:

    1. $ Sudo service httpd restart (CentOS6)
    2. $ 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.