CentOS 7.x PhpMyAdmin Install and Configure with Nginx

来源:互联网 发布:seo综合查询 编辑:程序博客网 时间:2024/06/05 18:20
In this Linux How to’s tutorial we will install and configure the latest version ofphpMyAdmin 4.4.9 to handle the database administration of MySQL, MariaDB and Drizzle servers over the web. It’s the best web based administration tool mainly for the beginner’s and for those who don’t feels comfortable with the command line administration. Its written in php so provides the intuitive web interface and supports most of the MySQL features to create and drop databases, create/drop/alter tables, delete/edit/add columns, execute any SQL statement and to manage indexes on columns.

Base Environment

We are going to install phpMyAdmin version 4.4.9 on the basic environment of Linux operating system with Nginx web server using MySQL’s Maria DB database and PHP. So, before starting the installation and configurations of phpMyAdmin make sure that you had already setup the LEMP Stack.

LEMP Stack Status

Check the status of Prerequisites that their services are enabled and running as we are going to install phpMyAdmin 4.4.9 under the following LEMP stack environment.

Linux

[root@CentOS-7 ~]# cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)

ENginx

[root@CentOS-7 ~]# nginx -v
nginx version: nginx/1.8.0

MySQL MariaDB

[root@CentOS-7 ~]# mysql -V
mysql Ver 15.1 Distrib 5.5.41-MariaDB, for Linux (x86_64) using readline 5.1

PHP

[root@CentOS-7 html]# php-fpm -v
PHP 5.4.16 (fpm-fcgi) (built: Oct 31 2014 13:01:14)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Start phpMyAdmin 4.4.9 Installation:

After we had confirmed that our basic environment to setup phpMyAdmin installation is fine, let's proceed with the following steps to setup phpMyAdmin.

STEP 1: Download phpMyAdmin 4.4.9 Package

Many operating systems already includes with its package but unfortunately in CentOs 7.1 its not available by default in its repositories. So we can install it with two different methods, one is to enable the EPEL repository first and then install it using following YUM commands.

[root@CentOS-7 ~]#yum install epel-release
[root@CentOS-7 ~]#yum install phpmyadmin

The second method is to download the latest release from its official web link.
So, we will follow the second method to download the latest release of phpMyAdmin 4.4.9 in tar.gz package.

[root@CentOS-7 tmp]# wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/4.4.9/phpMyAdmin-4.4.9-all-languages.tar.gz

STEP 2: Extract phpMyAdmin 4.4.9 Package

We will extract this .tar.gz package into the document root directory of Nginx to create its virtual host after that.

[root@CentOS-7 tmp]# tar zxvf phpMyAdmin-4.4.9-all-languages.tar.gz –C /usr/share/nginx/html/
[root@CentOS-7 tmp]# ls /usr/share/nginx/html/
phpMyAdmin-4.4.9-all-languages

Now change its name to a user friendly name with MV command. Let's move html directory first and change its name as.

[root@CentOS-7 tmp]# cd /usr/share/nginx/html/
[root@CentOS-7 html]# vm phpMyAdmin-4.4.9-all-languages phpMyAdmin
[root@CentOS-7 html]#ls
[root@CentOS-7 html]#phpMyAdmin

STEP 3: Configure phpMyAdmin Virtual Host

In order to access phpMyAdmin over the web we need to configure its virtual host. Create an new file within the default configuration directory of Nginx.

[root@CentOS-7 ~]# cd /etc/nginx/conf.d/
[root@CentOS-7 conf.d]# touch vitual.conf
[root@CentOS-7 conf.d]# vim virtual.conf
server {
server_name 172.25.10.177;
root /usr/share/nginx/html/;

location / {
index index.html index.htm index.php;
}

location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
}
}

Web Configurations of phpMyAdmin

Before we go to web access of phpMyAdmin, open its document root directory and rename or copy its configuration file to configure it as per requirements.

[root@CentOS-7 html]# cd /usr/share/nginx/html/phpMyAdmin/
[root@CentOS-7 phpMyAdmin]# cp config.sample.inc.php config.inc.php

Now we can access the phpMyAdmin Web Administration console after restart of Nginx and php-fpm services with following commands.

[root@CentOS-7 phpMyAdmin]# systemctl restart nginx.service
[root@CentOS-7 phpMyAdmin]# systemctl restart php-fpm.service

after getting services active status we are now ready to open our web browser to access phpMyAdmin Web Console and login with the root credentials of our MySQL Maria-DB Server.

http://172.25.10.177/phpMyAdmin/
http://localhost/phpMyAdmin/

phpMyAdmin Login

phpMyAdmin Missing Configurations

There are few missing configurations on the home page of phpMyAdmin Administration panel that we need to configure by making changes to the configuration file of phpMyAdmin. Let's follow the two steps to complete these two missing configurations.

phpMyAdmin Missing Conf

STEP 1: Add blowfish_secret passphrase

If you see the following error message at the bottom of your phpMyAdmin home page after your first login, then its means its missing Blowfish passowrd.

Blowfish Password

To figure out this problem just Open the configurations file of phpMyAdmin and add the encrypted password in front of blowfish_secret.

[root@CentOS-7 phpMyAdmin]# vim config.inc.php
$cfg['blowfish_secret'] = '5v}wtr0gDKnqOSDd8}nwzuoksuszpZNdLI-}2KE~n'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

STEP 2: Enabling Configuration Storage

This configuration is optional and should be disappeared after a refresh of page.

phpMyAdmin Storage Missing

To recover from this error message we will uncomment below lines from the phpmyAdmin configurations file as set the control username and password.

phpmyadmin stotage configs

Creating phpMyAdmin database and user

According to above configurations now we will create a controluser and then import the database from the document root of phpMyAdmin using following commands.

To Create User

MariaDB [(none)]> create user 'pma'@'localhost' identified by 'pma123';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye

To Import database

[root@CentOS-7 phpMyAdmin]# mysql -u root -p < /usr/share/nginx/html/phpMyAdmin/sql/create_tables.sql
Enter password:

Grant Privileges to Control User

To take advantage of the relational features and other bookmark, we will need to give pma control user with some additional permissions as shown.

User Privileges

Restart Services

We had done with all the setup and configurations of phpMyAdmin now to impliment these changes we have to restart nginx, mariadb and php-fpm services.

[root@CentOS-7 phpMyAdmin]#systemctl restart mariadb.service
[root@CentOS-7 phpMyAdmin]#systemctl restart nginx.service
[root@CentOS-7 phpMyAdmin]#systemctl restart php-fpm.service

Now logout from the previous session and refresh your web browser or open it in new window with same following URL. The error messages at the bottom of the main screen should now gone away.

http://172.25.10.177/phpMyAdmin/
http://localhost/phpMyAdmin/

Ready to go with phpMyAdmin Bringing MySQL to the web

phpMyadmin Home

CONCLUSION

We had successfully installed and configured phpMyAdmin with all security parameters to an awesome open source tool for the administration of databases. Its so helpful for the newbies and for the professional as it also provide us with its console option to execute queries. So, get ready to setup your own phpMyAdmin environment and feel free to comment us back.

0 0
原创粉丝点击