Install PhpMyadmin Ubuntu 20.04 Apache2

Dixmata Studio
4 min readApr 8, 2022

Install PHPMyadmin Ubuntu. In this post, we will share how to Install PhpMyadmin Latest Version using the Ubuntu 20.04 Apache OS. Phpmyadmin is free software written in the PHP programming language which is used to handle MySQL administration through the Jejaring Jagat Jembar website (World Wide Web)

Source : Install PhpMyAdmin Ubuntu | Dixmata Labs

Advantages of phpmyadmin

  • It has a web-based graphical interface so that it can be accessed widely.
  • Supports many MySQL features
  • Can import data from SQL and CSV
  • Provides data export in various formats such as SQL, XLS, CSV, XML, PDF and Text.
  • There is monitoring of server processes such as connections, processors, memory and so on.
  • And there are many other advantages.

Langkah 1 : Install Apache WebServer

The function of the web server is to manage websites that are online. To keep everything running smoothly, the web server acts as an intermediary between the server machine and the client. The web server pulls content from the server at each user’s request and sends it to the web.

apt update -y
apt install apache2 -y

By default apache2 is running automatically after being installed and to see the status of apache2 running, you can see it with the following command

systemctl status apache2

If the apache2 status is not running, you can run the command below.

systemctl start apache2

If it’s running well, type in your browser the ip address of the server. http://[your-ip-address].

Langkah 2 : Install Php 7.4 (Install PhpMyadmin Ubuntu 20.04)

For php 7.4 on OS Ubuntu 20.04 it can be directly installed without additional repositories. First do the update on the OS

apt update -y
apt install php

Followed by installing the php script.

apt install php php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-mysqli -y

Automatically installed php is php 7.4

PHP 7.2

And if you want to use php 7.2, you need to add a php repository.

apt install software-properties-common -y
add-apt-repository ppa:ondrej/php -y

Then update

apt update -y

Do install php script

apt install -y php7.2
apt-get install php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml

Step 3: Install PhpMyAdmin and Download PhpMyadmin Ubuntu 20.04

Install PhpMyAdmin latest version, to find the latest/latest version of PhpMyAdmin can be seen on the official website of phpmyadmin

cd /home
wget https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.zip
apt install unzip -y
unzip phpMyAdmin-5.1.1-all-languages.zip

then move the unzipped phpmyadmin folder into the /share folder

mv phpMyAdmin-*/ /usr/share/phpmyadmin

the next step is to create a directory for the phpmyadmin temp file, then set the permissions.

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

Create a directory from phpmyadmin, this works if you want to use authentication password

mkdir /etc/phpmyadmin

Step 4: Edit the PhpMyAdmin Configuration File

Rename the phpmyadmin configuration file.

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

Edit the config.inc.php file and enter blowfish_secret

nano /usr/share/phpmyadmin/config.inc.php

Look for $cfg[‘blowfish_secret’] then fill in the generate secret like the command below:

$cfg['blowfish_secret'] = 'VlhyKab[niEixkYCfMepu:wC4c=0fzb,';

Create a Temp directory in the phpmyadmin configuration:

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

Step 5: Configure Apache Web Server (Install PhpMyadmin Ubuntu 20.04)

and Added Apache config file inside the file:

nano /etc/apache2/conf-enabled/phpmyadmin.conf

copy/paste the following command:

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>

after that restart the apache web server

systemctl restart apache2

Step 6: Install Mysql Database Server (Install PhpMyadmin Ubuntu 20.04)

Install Mysql-Server as database:

apt install mysql-server -y

Provide password for database

sudo mysql_secure_installation

Enter the database via the following command.

mysql -u root

Create a database user and password with the same privileges as root.

CREATE USER 'usertest'@'localhost' IDENTIFIED BY 'Your-Password';
GRANT ALL PRIVILEGES ON *.* TO 'usertest'@'localhost';
FLUSH PRIVILEGES;
exit

Step 7 : Access PhpMyAdmin in Browser

If it’s running well, type in your browser the ip address of the server. http://[your-ip-address] or http://[yourdomain/phpmyamdin]

Akses URL http://[Your-Ipaddress]/phpmyadmin

Overview of the PhpMyAdmin Install Documentation, Hopefully it is useful and can be a lesson for all of us. If anyone has any doubts, you can ask the comments column regarding Install PhpMyAdmin and other documentation. Sorry if there are mistakes in Documentation and also mistakes in wording. We ask for your criticism and suggestions so that we can build this website even better. For how to install Ubuntu 20.04, friends, you can check on Cara Install Ubuntu 20.04 Server Dixmata Labs

--

--

Dixmata Studio

Dixmata Labs adalah website tutorial Belajar Linux Fundamental , Installasi Hardware dan Software yang berkaitan dengan Linux.