INSTALL APACHE2, PHP 8, MARIADB (MYSQL) AND PHPMYADMIN ON LINUX
If you have not already done so, download the "PuTTY" program.
Use PuTTY to connect to your root or vServer via SSH. To do this, open PuTTY and enter the domain or IP address of your server in the "Host Name (or IP address)" text field. Then click OK at the bottom.
Now update your package lists with the apt update command.
Install any available updates of the packages already installed on your server with the command apt upgrade -y
Next, install the packages that are required for further installations with the following command: apt install ca-certificates apt-transport-https lsb-release gnupg curl nano unzip -y
Add the package source needed to install PHP 8: For Debian:
Using the command wget -q add https://packages.sury.org/php/apt.gpg -O- | apt-key add - add the key required for the PHP package source.
Use the command echo "deb https://packages.sury.org/php/ $ (lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list to add the package source.
Install the package source management package using the following command: apt install software-properties-common -y
Use the command add-apt-repository ppa: ondrej/php to add the repository now.
Now update your package lists again using the apt update command.
Install the Apache2 web server and other required packages with the following command: apt install apache2 -y
Then install PHP 8 as well as some important PHP modules. The command for this is: apt install php8.0 php8.0-cli php8.0-common php8.0-curl php8.0-gd php8.0-intl php8.0-mbstring php8.0-mysql php8.0-opcache php8.0-readline php8.0-xml php8.0-xsl php8.0-zip php8.0-bz2 libapache2-mod-php8.0 -y
Next, install the MariaDB server and client (MySQL) using the apt install mariadb-server mariadb-client -y command.
Now enter the command mysql_secure_installation to safely complete the configuration of the MariaDB server. The first time you are asked for the current password, you do not have to enter anything, just press the Enter key. Confirm the next question regarding changing the root password with Enter. Now you have to assign a password for the root user of the MariaDB server. No characters appear as you type, but this is normal. Confirm all the following questions (deleting the anonymous user, prohibiting the external root login for security reasons, removing the test database and updating the rights) with Enter. Then the MariaDB server is completely installed and configured.
Change to the directory where phpMyAdmin will be installed with the command cd /usr/share
To download phpMyAdmin, run the command wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip -O phpmyadmin.zip
Unzip the archive you just downloaded with the following command: unzip phpmyadmin.zip
Remove the downloaded archive, which is now already unzipped, with the command rm phpmyadmin.zip
Then you have to rename the name of the extracted directory to "phpmyadmin". You do this with the following command: mv phpMyAdmin - * - all-languages phpmyadmin
Then assign the required rights to the phpMyAdmin directory using the command chmod -R 0755 phpmyadmin
Now create an Apache2 configuration file for phpMyAdmin by running the command nano /etc/apache2/conf-available/phpmyadmin.conf
Now add the following content to this configuration file:
# Disallow web access to directories that don't need it
Require all denied
Require all denied
Require all denied
Save your changes to the configuration by pressing CTRL + X, then the "Y" key and then press Enter.
Activate the Apache2 configuration file you just added with the a2enconf phpmyadmin command and then run the systemctl reload apache2 command to reload the Apache2 web server.
Create the temporary directory that phpMyAdmin needs by executing the command mkdir /usr/share/phpmyadmin/tmp/
Now give the web server user the required owner rights for this temporary directory using the command chown -R www-data: www-data /usr/share/phpmyadmin/tmp/
Note: For security reasons, you can no longer log into the MariaDB server directly as a root user using the normal password authentication (e.g. via phpMyAdmin). You can either enable this anyway (not recommended on production systems) or, alternatively, create another user with all rights (recommended) if you need this (e.g. for phpMyAdmin). You will find an explanation of these two options in the next two steps.
Variant 1 - enable root login via password authentication (not recommended on productive systems): Log into PuTTY using the command mysql -u root on the MariaDB server and then run the commands UPDATE mysql.user SET plugin = 'mysql_native_password 'WHERE user =' root ' AND plugin =' unix_socket '; and FLUSH PRIVILEGES; the end. This changes the authentication plug-in of the root user from the UNIX socket back to standard authentication. Finally, exit the MariaDB console with the exit command.
Variant 2 - Create additional user with all rights (recommended): Log into PuTTY using the command mysql -u root on the MariaDB server and then execute the commands CREATE USER 'username' @ 'localhost' IDENTIFIED BY 'password' ; and GRANT ALL PRIVILEGES ON *. * TO 'username' @ 'localhost' WITH GRANT OPTION; the end. Replace "username" and "password" with your desired username and password. Finally, exit the MariaDB console with the exit command. You can then log in to the MariaDB server with the newly created user (e.g. via phpMyAdmin).
Your Apache2 web server including PHP 8, MariaDB server and phpMyAdmin is now ready for use. By default, the web directory is located under "/var/www/html /". You can access the phpMyAdmin web interface by adding "/phpmyadmin" to the IP address or domain of your server in the browser. There you can now log in to the MariaDB server - depending on which variant you selected after step 25, either with the "root" user or with your additionally created user.