How To Install PHPMyAdmin on Kali Linux 2022.x

Posted on 192 views

PHPMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web interface. phpMyAdmin supports a wide range of operations on MySQL and MariaDB. In this article we look at how you install PHPMyAdmin on Kali Linux & Debian Linux system.

Most frequent database operations – (managing databases, tables, columns, relations, indexes, users, permissions, etc) can be performed via the web console, while you still have the ability to directly execute any SQL statement.

phpadmin

Core Features of phpMyAdmin

  • An intuitive cool web interface
  • Support for most MySQL features
  • Import data from CSV and SQL
  • Export data to various formats: CSV, SQL, XML, PDF, ISO/IEC 26300 – OpenDocument Text and Spreadsheet, Word, LATEX, and others
  • Administering multiple servers
  • Creating PDF graphics of your database layout
  • Creating complex queries using Query-by-example (QBE)
  • Searching globally in a database or a subset of it
  • Transforming stored data into any format using a set of predefined functions, like displaying BLOB-data as image or download-link

The following is the procedure to follow while installing PHPMyAdmin on Kali Linux or any other Debian based system.

Step 1: Update System

Start by ensuring the system is updated.

sudo apt update
sudo apt upgrade

Because of kernel updates a reboot may be required.

sudo reboot

Step 2: Install PHP and Apache on Kali Linux

The next step is the installation of 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 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’re using phpMyAdmin to administer MySQL or MariaDB database server you should have database server already installed. You can also reference our guides below.

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

Step 4: Install PHPMyAdmin on Kali Linux

From the phpMyAdmin downloads page you should be able to check the latest release.

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

wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

Extract downloaded archive file using tar:

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

Move the folder created from extraction to /usr/share/phpmyadmin directory.

rm -f phpMyAdmin-latest-all-languages.tar.gz
sudo mv phpMyAdmin-*/ /usr/share/phpmyadmin

Create directory for phpMyAdmin temp 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 where phpMyAdmin configuration files will be stored.

sudo mkdir /etc/phpmyadmin/

Copy configuration template to the directory we just created.

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

Edit the file /usr/share/phpmyadmin/config.inc.php and set secret passphrase:

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

Configure Temp directory by adding this line in the file.

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

Step 5: Configure Apache web Server

Create a new Apache configuration file for phpMyAdmin.

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

Paste below contents to the file.

Alias /phpmyadmin /usr/share/phpmyadmin


    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php

    
        
            AddType application/x-httpd-php .php
        
        
            SetHandler application/x-httpd-php
        

        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
    
    
        
            AddType application/x-httpd-php .php
        
        
            SetHandler application/x-httpd-php
        

        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
    



# Authorize for setup

    
        
            AuthType Basic
            AuthName "phpMyAdmin Setup"
            AuthUserFile /etc/phpmyadmin/htpasswd.setup
        
        Require valid-user
    


# Disallow web access to directories that don't need it

    Require all denied


    Require all denied


    Require all denied

Restriction to specific IP addresses or network address block can be set with a configuration which looks similar to below.

Require ip 127.0.0.1 192.168.10.0/24

Finally restart Apache web server to read the changes.

sudo systemctl restart apache2

Confirm Apache service has been started without any error:

$ 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 2022-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 6: Open phpMyAdmin Web interface

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

phpmyadmin-debian-10-login

Use your database credentials – username & password to login. The root user credentials can also be used to authenticate.

phpMyAdmin dashboard is displayed upon a successful login.

phpmyadmin-debian-10-dashboard-1024x546

You can now use phpMyAdmin for all database management tasks in your software development cycle. Below are more guides we have on Kali Linux.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.