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)

Advantages of phpmyadmin

Install PhpMyadmin

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 (Install PhpMyadmin Ubuntu 20.04)

PHP 8.0

To install PHP 8.0, you must activate the Repository first, follow the following command.

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

After successfully activating the Repo now you can install PHP 8.0

apt install -y php8.0
apt-get install php-pear php8.0-curl php8.0-dev php8.0-gd php8.0-mbstring php8.0-zip php8.0-mysql php8.0-xml

Verifikasi Version PHP

php -v

Output

PHP 8.0.19 (cli) (built: May 17 2022 18:48:59) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.19, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.19, Copyright (c), by Zend Technologies

PHP 7.4

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

Move to Directory Home

cd /home

To Install PhpMyadmin Ubuntu, download the PhpMyadmin Package

wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip

If the Ubuntu PhpMyAdmin install package is downloaded successfully, Unzip the PhpMyAdmin Package

apt install unzip -y
unzip  phpMyAdmin-5.2.0-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.

If you get an error like this

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
 ... Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.

Then we have to change the MySQL Authentication password first.

Login to MySQL > Follow the following command

mysql

Then run the command replace MySQL Authentication

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by ')8#<D)u_R2fcbWpL';

If it is successful, then we can run the mysql_secure_installation command. Run the command to continue Installing PhpMyAdmin Ubuntu

mysql_secure_installation

MySQL will ask to input the root password, fill in the password that we changed earlier, namely )8#<D)u_R2fcbWpL

MySQL will confirm > Type Y

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : Y

Enter new password

New password:

Re-enter new password:

If you have followed the next step Remove anonymous users? > type Y

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.

Disallow root login remotely? > Type “Y”

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

Remove test database and access to it? > Type “Y”

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.

Reload privilege tables now? > Type “Y”

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done!

Congratulations Now you have successfully changed Password by using mysql_secure_installation.

Confirm the new password by logging into MySQL and Entering the new Password

mysql -u root -p

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

Install PhpMyadmin

Confirm login using the root user that we have changed the password.

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

Source : Install PhpMyAdmin Ubuntu | Medium