phpMyAdmin
Install phpMyAdmin php
sudo apt -y install wget php php-cgi php-pear php-mbstring php8.2-gettext libapache2-mod-php php-common php-phpseclib php-mysql
cd /tmp DATA="$(wget https://www.phpmyadmin.net/home_page/latest.txt -q -O-)" URL="$(echo $DATA | cut -d ' ' -f 3)" VERSION="$(echo $DATA | cut -d ' ' -f 1)" wget https://files.phpmyadmin.net/phpMyAdmin/${VERSION}/phpMyAdmin-${VERSION}-all-languages.tar.gz tar xvf phpMyAdmin-${VERSION}-all-languages.tar.gz
Delete compressed file and move the resulting folder to /usr/share/phpmyadmin folder.
rm *.tar.gz sudo mv phpMyAdmin-*/ /var/www/phpmyadmin
Create directory for phpMyAdmin temp files.
sudo mkdir -p /var/lib/phpmyadmin/tmp sudo chown -R www-data:www-data /var/lib/phpmyadmin sudo mkdir /etc/phpmyadmin/ sudo cp /var/www/phpmyadmin/config.sample.inc.php /var/www/phpmyadmin/config.inc.php nano /var/www/phpmyadmin/config.inc.php
#Edit the file and set secret passphrase: $cfg['blowfish_secret'] = 'H2OxcGXxflSd8JwrwVlh6KW6s2rER63i'; //Configure Temp directory by add $cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';
nano /etc/apache2/conf-available/phpmyadmin.conf
# phpMyAdmin default Apache configuration Alias /pma /var/www/phpmyadmin <Directory /var/www/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 /var/www/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/var/www/php/php-gettext/:/var/www/php/php-php-gettext/:/var/www/javascript/:/var/www/php/tcpdf/:/var/www/doc/phpmyadmin/:/var/www/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 /var/www/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/var/www/doc/phpmyadmin/:/usr/share/php/phpseclib/ php_admin_value mbstring.func_overload 0 </IfModule> </Directory> # Authorize for setup <Directory /var/www/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 /var/www/phpmyadmin/templates> Require all denied </Directory> <Directory /var/www/phpmyadmin/libraries> Require all denied </Directory> <Directory /var/www/phpmyadmin/setup/lib> Require all denied </Directory>
You can restrict access from specific IP by adding line like below
Require ip 127.0.0.1 192.168.18.0/24
a2enconf phpmyadmin.conf systemctl reload apache2 systemctl restart apache2
Visit phpMyAdmin Web interface Open the URL http://[ServerIP/Hostname]/pma to login into phpMyAdmin dashboard with your Database credentials – username & password.