How to install PHPMyAdmin on Kali Linux 2020.x

You can download this article in PDF format via the link below to support us.Download the guide in PDF formatClose

PHPMyAdmin is a free software tool written in PHP, designed to handle MySQL management through a web interface. phpMyAdmin supports multiple operations on MySQL and MariaDB. In this article, we introduced how to install PHPMyAdmin on Kali Linux and Debian Linux systems.

The most common database operations-(manage databases, tables, columns, relationships, indexes, users, permissions, etc.) can be performed through the Web console, and you can still execute any SQL statement directly.

Core functions of phpMyAdmin

  • Intuitive and cool web interface
  • Supports most MySQL functions
  • Import data from CSV and SQL
  • Export data to various formats: CSV, SQL, XML, PDF, ISO/IEC 26300-OpenDocument text and spreadsheet, Word, LATEX, etc.
  • Manage multiple servers
  • Create PDF graphics of database layout
  • Use sample queries (QBE) to create complex queries
  • Global search in the database or its subset
  • Use a set of predefined functions to convert stored data into any format, such as displaying BLOB data as an image or download link

Below is the process to follow when installing PHPMyAdmin on Kali Linux or any other Debian based system.

Step 1: Update the system

First make sure that the system has been updated.

sudo apt update
sudo apt upgrade

Due to a kernel update, a reboot may be required.

sudo reboot

Step 2: Install PHP and Apache

The next step is to install PHP, required modules and Apache Web Server.

sudo apt -y update
sudo apt -y install wget php php-cgi php-mysqli php-pear php-mbstring libapache2-mod-php php-common php-phpseclib php-mysql

Confirm the installation of PHP by checking the version:

$ php --version
PHP 7.4.11 (cli) (built: Oct  6 2020 10:34:39) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.11, Copyright (c), by Zend Technologies

Step 3: Install MariaDB / MySQL database server

Since you are using phpMyAdmin to manage the MySQL or MariaDB database server, you should already have the database server installed. You can also refer to our guide below.

How to install MariaDB on Kali Linux

How to install MySQL 8.0 on Kali Linux

Once the database server is installed and running, you can proceed to install phpMyAdmin on Kali Linux and Debian systems.

Step 4: Install PHPMyAdmin on Kali Linux | Debian

From phpMyAdmin Download page You should be able to check the latest version.

Use the wget command line tool to download the latest version of phpMyAdmin:

wget https://files.phpmyadmin.net/phpMyAdmin/5.0.4/phpMyAdmin-5.0.4-all-languages.tar.gz

Use tar to extract the downloaded archive file:

tar xvf phpMyAdmin-5.0.4-all-languages.tar.gz

Unzip the created folder from to /usr/share/phpmyadmin table of Contents.

sudo mv phpMyAdmin-*/ /usr/share/phpmyadmin

Create a directory for phpMyAdmin temporary files.

sudo mkdir -p /var/lib/phpmyadmin/tmp
sudo chown -R www-data:www-data /var/lib/phpmyadmin

We also need to create a directory to store phpMyAdmin configuration files.

sudo mkdir /etc/phpmyadmin/

Copy the configuration template to the directory we just created.

sudo cp /usr/share/phpmyadmin/config.sample.inc.php  /usr/share/phpmyadmin/config.inc.php

Edit file /usr/share/phpmyadmin/config.inc.php And set a secret password:

$ sudo vim /usr/share/phpmyadmin/config.inc.php
$cfg['blowfish_secret'] = 'H2TxcGXxflSd8JwrXVlh6KW4s2rER63i'; 

Configure the Temp directory by adding this line in the file.

$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';

Step 5: Configure the Apache web server

Create a new Apache configuration file for phpMyAdmin.

sudo vim /etc/apache2/conf-enabled/phpmyadmin.conf

Paste the following content into the file.

Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php

    <IfModule mod_php5.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>

        php_value include_path .
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
        php_admin_value mbstring.func_overload 0
    </IfModule>
    <IfModule mod_php.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>

        php_value include_path .
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
        php_admin_value mbstring.func_overload 0
    </IfModule>

</Directory>

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authz_core.c>
        <IfModule mod_authn_file.c>
            AuthType Basic
            AuthName "phpMyAdmin Setup"
            AuthUserFile /etc/phpmyadmin/htpasswd.setup
        </IfModule>
        Require valid-user
    </IfModule>
</Directory>

# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/templates>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/libraries>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Require all denied
</Directory>

You can use the configuration shown below to set restrictions on specific IP addresses or network address blocks.

Require ip 127.0.0.1 192.168.10.0/24

Finally, restart the Apache web server to read the changes.

sudo systemctl restart apache2

Confirm that the Apache service has been started without any errors:

$ systemctl status apache2                                                                                                                                                                                            
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: disabled)
     Active: active (running) since Fri 2021-01-22 14:49:54 EST; 11min ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 7502 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 7513 (apache2)
      Tasks: 11 (limit: 2274)
     Memory: 57.8M
        CPU: 656ms
     CGroup: /system.slice/apache2.service
             ├─7513 /usr/sbin/apache2 -k start
             ├─7515 /usr/sbin/apache2 -k start
             ├─7516 /usr/sbin/apache2 -k start
             ├─7517 /usr/sbin/apache2 -k start
             ├─7518 /usr/sbin/apache2 -k start
             ├─7519 /usr/sbin/apache2 -k start
             ├─7751 /usr/sbin/apache2 -k start
             ├─7757 /usr/sbin/apache2 -k start
             ├─7758 /usr/sbin/apache2 -k start
             ├─7759 /usr/sbin/apache2 -k start
             └─7760 /usr/sbin/apache2 -k start

Step 5: Open the phpMyAdmin Web interface

Access the phpMyAdmin web interface on http://[ServerIP|Hostname]/phpmyadmin

phpmyadmin debian 10 login

Log in with your database credentials-username and password.of root User credentials can also be used for authentication.

After a successful login, the phpMyAdmin dashboard will be displayed.

phpmyadmin debian 10 dashboard

Now you can use phpMyAdmin for all database management tasks in the software development cycle. Here are more guides we have on Kali Linux.

How to install GNS3 on Kali Linux Rolling

How to install AnyDesk on Kali Linux

How to install Visual Studio Code on Kali Linux

You can download this article in PDF format via the link below to support us.Download the guide in PDF formatClose

Sidebar