arrow_upward

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Easy phpMyAdmin Installation On Linux
#1
Easy phpMyAdmin Installation On Linux
[Image: tkpP9Xw.png]


Howdy Post4VPS!

Welcome to another Post4VPS user request based tutorial for the command-line installation of software and applications on Linux servers. In this guide I will teach you how to easily install the phpMyAdmin web application on your Linux based server with a web server, PHP and a MySQL based database server. If you want to know how to install a web server with PHP and MariaDB you can take a look at the following instructions: Host Your Own WP Blog Using Debian 10, Nginx, PHP 8 & MariaDB. A small additional information: phpMyAdmin is a web application that is meant to be downloaded, unzipped and used after a bit of configuration. Therefore I highly recommend to install it from the official source and always use the latest available version. Don't rely on the phpMyAdmin software packages that you can install via package managers in Linux distributions! This way wou will have the latest phpMyAdmin and thus will lower the risk of opening security holes in your web hosting stack. Also keep in mind to always update to the latest phpMyAdmin version afterwards!

This tutorial will NOT cover the following points: a) how to install and configure a web server like Apache or Nginx, b) how to install and configure PHP (e.g. PHP 8) and c) how to install and configure a MySQL database server like MariaDB. You can use the previously linked guide to learn how to do that based on Nginx, PHP 8 and MariaDB. Other kind of setups using different web servers and / or database servers can be found in this forum or all around the web. Additionally this tutorial will not include steps that may help you to secure your phpMyAdmin installation. This is due to different web servers offering different ways to secure it. This subject alone would be worth a dedicated standalone tutorial (in my opinion at least).

Below is the setup I'm going to use during this tutorial:
  • Intel Pentium N4200 4x 2.4 GHz
  • 4 GB DDR4 2400 MHz RAM
  • 64 GB eMMC Flash Storage
  • Debian "Buster" 10 64 Bit
  • Nginx Stable 1.20
  • PHP 8.0
  • MariaDB 10.5

This is the very same server that I used when I created the previous guide that I linked above. It serves well as an example system to perform a phpMyAdmin installation to make the management of databases easier. Although you may know that I'm not a big of of any kind of control panels, I admin that I'm happily using phpMyAdmin when necessary to quickly create users, databases or perform other operations like database optimization or backups. However, I strongly recommend to secure any phpMyAdmin installation by mainly limiting access to it to a certain set of IP addresses (and as mentioned before: always keep it up-to-date!).



Before we start with the main parts of the guide I have some additional information for you.


Easy is not very easy
- In the past the installation of phpMyAdmin basically used to be very easy. It was mainly: a) download the latest version, unzip the latest version and c) adjust a little part of the configuration file. After this three main steps it was basically ready to go. New security measures introduced by MySQL and thus MySQL based database servers require some more work now. The main necessity is the creation of a dedicated database user with full administration rights that can be used in phpMyAdmin for any administrative operations. Earlier it was possible to simply use the root user but this has been disabled to increase security.

Different web hosting stacks require different phpMyAdmin versions
- Certain parts of web hosting stacks such as the PHP version and MySQL server version dictate which phpMyAdmin version you can use or rather said need to use to have a working instance of phpMyAdmin running. So be careful here and watch out what kind of software versions you are using and which phpMyAdmin version you need. I will only mention it this time and no other time during the whole tutorial. Example if you have PHP 8.0 and MySQL 5.5 or MariaDB you need to get the latest stable version 5.1.0 of phpMyAdmin. The older but still supported version (security fixes only) 4.9.7 will not work with PHP 8.0.
- PHP 7.1 and newer and MySQL/MariaDB 5.5 and newer -> phpMyAdmin 5.1.0.
- PHP 5.5 to 7.4 and MySQL/MariaDB 5.5 and newer -> phpMyAdmin 4.9.7.

No phpMyAdmin software packages from Linux distribution package managers
- As mentioned before we will not be using phpMyAdmin software packages that can be installed by package managers coming with Linux distributions like apt, yum or similar. Most are out of date and are only tailored to web hosting stack software version that are also available by default through the package managers on the Linux distributions. As easy as that would make it to install phpMyAdmin it's simply not the right way where you will learn how to install it yourself and it most likely will not compatible with different web hosting stacks (e.g. might only work with Apache installed by the package manager but will not work with Nginx).



Prerequisites

First we will install a few necessary tools via apt. To do that first connect to your server and login (best would be to login as root or a user with sudo access as you will need administrative permissions to run some of the commands).

Run the following command in your terminal as root or a user with sudo access (remember to add sudo before the command) to install the necessary tools:
apt-get install wget nano ca-certificates tar gzip -y

The command will install the CLI downloader "wget", the CLI text editor "nano", the TLS CA certificate base (to download from HTTPS links without certificate errors) and the archive management tool tar + gzip for tar and gunzip archives.



phpMyAdmin MySQL Administration User

Next step before the phpMyAdmin installation is the creation of the necessary MySQL administration user that you can use in phpMyAdmin instead of the MySQL root user.

Start the MySQL CLI management console as the MySQL root user:
mysql -u root -p
(Enter your MySQL root password when prompted.)

Create a new user that will become the administrator:
CREATE USER 'pmaadmin'@'localhost' IDENTIFIED BY 'mypassword123';
(I'll use pmaadmin as the username. Remember to adjust it to your liking and also set your own password instead of mypassword123.)

Grant all permissions to all databases and also special permission to the new user:
GRANT ALL PRIVILEGES ON *.* TO 'pmaadmin'@'localhost' WITH GRANT OPTION;

Reload all user privileges:
FLUSH PRIVILEGES;

Exit the MySQL CLI tool:
exit
(Remember to adjust the username to yours!)

You now have a MySQL user that basically has a lot of power over the database server. It is like the MySQL root user. You will use this use to login in phpMyAdmin when you need to create a new user/database or do other administrative tasks.



phpMyAdmin Installation

Now we can finally perform the phpMyAdmin installation.

Change your directory to the folder containing your website (where you want to install phpMyAdmin):
cd /var/www/hiddenrefuge.eu.org
(Adjust the path to your own website on your own web hosting stack.)

Download the latest version that is compatible with your web hosting stack. You can get the download links on this page. Take the download link for the archive file ending with tar.gz.
wget https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-all-languages.tar.gz
(Here you would use the link for the correct and latest version.)

Extract the downloaded phpMyAdmin archive:
tar -zxvf phpMyAdmin-5.1.0-all-languages.tar.gz
(Here you should use the file name of the version you downloaded.)

You will now have a folder called like the archive name (without .tar.gz). Rename this folder to a easier to remember name:
mv phpMyAdmin-5.1.0-all-languages sqlmgmt
(Here you should use the folder name of your version and your new wish name for the folder. Make it something not so obvious to prevent bots trying to look for phpMyAdmin - so AVOID calling the folder pma or phpmyadmin/phpMyAdmin!)

You can now remove the downloaded tar.gz archive:
rm -rf phpMyAdmin-5.1.0-all-languages.tar.gz
(Here you should use the file name of the version you downloaded.)

Set correct ownership/permissions for the phpMyAdmin folder:
chown -R nginx:nginx /var/www/hiddenrefuge.eu.org/sqlmgmt
(Here you should adjust the user and group to the one you use for the web server and PHP processes. Additionally remember to adjust the path to your phpMyAdmin folder.)

To verify that you can access phpMyAdmin and it works (not displaying any kind of errors or something) should open the phpMyAdmin instance on your website in a web browser.

You should see this page:
[Image: pBApgyV.png]


phpMyAdmin Configuration

After the phpMyAdmin installation it is necessary to configure a few things or else you will not be able to use phpMyAdmin properly.

Change directory in to your phpMyAdmin folder:
cd /var/www/hiddenrefuge.eu.org/sqlmgmt
(Adjust the path to your phpMyAdmin installation.)

Rename the sample configuration file to the main configuration file name:
mv config.sample.inc.php config.inc.php

Open the configuration file with nano:
nano /var/www/hiddenrefuge.eu.org/sqlmgmt/config.inc.php
(Adjust the path to your phpMyAdmin installation.)

Go to this page and generate yourself a new blowfish secret.

Inside your configuration file replace
Quote:$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

With the new configuration line with your blowfish secret from the page, e.g.:
Quote:$cfg['blowfish_secret'] = 'MN66UsUnxf,uVql{Dt1uzCE[cnE5M6Rb';
(Don't use the blowfish secret from the example above! Get your own from the page that I linked to above.)

Save the file with CTRL + O and ENTER. Exit the nano text editor with CTRL + X.

This is about it in terms of the configuration of phpMyAdmin.


Getting started with phpMyAdmin

Now navigate to your phpMyAdmin installation on your website via web browser and try to login with the user that you created during the phpMyAdmin MySQL Administration User setup step.

[Image: m39NtjU.png]

If everything went well you should be in and it should look like this:
[Image: kGhTppC.png]

Do you see the warning message at the bottom of the screenshot? You need to do a little something to fix this issue.

Go to http://hiddenrefuge.eu.org/sqlmgmt/index...-relations in your web browser. Remember to adjust the part before "index.php?route=/check-relations" to the web address of your phpMyAdmin installation.

You will see the error below:
[Image: MGIommv.png8]

To fix this click on the blue "Create" link. This will generate a databse called phpmyadmin where phpMyAdmin will store its own configuration changes and settings.

After that you can go back to the main page of phpMyAdmin and the warning message should be gone.


That's all folks! You now have installed phpMyAdmin. To update it you would simply download the latest version and overwrite all files. The configuration files config.inc.php will remain unchanged. After overwritting the files you also have to set the ownership/permission again. You would basically simply repeat the phpMyAdmin Installation part with a newer version.
[Image: zHHqO5Q.png]


Messages In This Thread
Easy phpMyAdmin Installation On Linux - by Mashiro - 05-26-2021, 04:45 PM


person_pin_circle Users browsing this thread: 2 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting