HostOnNet Blog

Install phpMyAdmin in RHEL/CentOS/Ubuntu/Debian

Looking for Linux Server Admin or WordPress Expert? We can help.

Download latest version of phpMyAdmin from

http://www.phpmyadmin.net/home_page/downloads.php

cd /usr/local/src
wget https://files.phpmyadmin.net/phpMyAdmin/4.7.4/phpMyAdmin-4.7.4-english.tar.xz
tar xvf phpMyAdmin-4.7.4-english.tar.xz
mkdir /usr/hostonnet
rm -rf /usr/hostonnet/phpmyadmin
mv phpMyAdmin-4.7.4-english /usr/hostonnet/phpmyadmin
cp /usr/hostonnet/phpmyadmin/config.sample.inc.php /usr/hostonnet/phpmyadmin/config.inc.php

You need to edit /usr/hostonnet/phpmyadmin/config.inc.php and set a random string for $cfg[‘blowfish_secret’]

vi /usr/hostonnet/phpmyadmin/config.inc.php

You can use any 32 char length random string, if you are on Ubuntu, generate one with command

pwgen 32

Configure CentOS

Now create apache configuration file

vi /etc/httpd/conf.d/phpmyadmin.conf

Add following to the file

Alias /phpmyadmin "/usr/hostonnet/phpmyadmin"

<Directory "/usr/hostonnet/phpmyadmin">
    AllowOverride All
    Options FollowSymlinks
    Order allow,deny
    Allow from all
</Directory>

If Apache 2.4, you will get error

AH01630: client denied by server configuration: /usr/hostonnet/phpmyadmin

In this cause, use following config

Alias /phpmyadmin "/usr/hostonnet/phpmyadmin"
 
<Directory "/usr/hostonnet/phpmyadmin">
    AllowOverride All
    Options FollowSymlinks
    Order allow,deny
    Allow from all
    Require all granted
</Directory>

You can check apache version with

[root@server1 ~]# httpd -V
Server version: Apache/2.4.6 (CentOS)
Server built:   Aug 23 2017 15:47:21
Server's Module Magic Number: 20120211:24
Server loaded:  APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
[root@server1 ~]# 

Restart Apache web server

service httpd restart

Configure Ubuntu/Debian

Create file

vi /etc/apache2/conf-available/phpmyadmin.conf

Add

Alias /phpmyadmin "/usr/hostonnet/phpmyadmin"

<Directory "/usr/hostonnet/phpmyadmin">
    AllowOverride All
    Require all granted
    Options FollowSymlinks
    Order allow,deny
    Allow from all
</Directory>

Now enable config

a2enconf phpmyadmin

Restart Apache

service apache2 restart

Now you will be able to access phpMyAdmin by going to URL

http://your-server-ip/phpmyadmin

Posted in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.