Logo

How to Install phpMyAdmin on Debian 11

Try this guide with our instant dedicated server for as low as 40 Euros

Learning how to install phpMyAdmin on Debian 11 can significantly enhance your ability to manage MySQL and MariaDB databases efficiently. 

phpMyAdmin is a powerful web-based tool that simplifies database administration through a user-friendly interface. By the end of this tutorial, you’ll have all the knowledge to install phpMyAdmin on Debian, ensuring you can manage your databases with ease and precision.

The Prerequisites to Installing phpmyadmin on Debian 11

Before you install phpMyAdmin on Debian 11, ensure you have the following:

– A Debian 11 server

– A user account with root or sudo privileges

– You have a LAMP (Linux, Apache, MySQL/MariaDB, PHP) stack installed and configured on the server.

Table Of Contents

  1. Install phpmyadmin on Debian 11 Servers
    1. Step #1: Install LAMP Cluster on Debian 11
    2. Step #2: Download phpMyAdmin
    3. Step 3: Check phpMyAdmin GPG Key
    4. Step 4: Unpack and Configure phpMyAdmin
    5. Step 5: Access phpMyAdmin in Browser
  2. Conclusion
  3. FAQs

Install phpmyadmin on Debian 11 Servers

Let us go through the major steps of installing phpmyadmin on Debian 11 machines. 

Step #1: Install LAMP Cluster on Debian 11

To install phpMyAdmin on Debian, the LAMP stack must be properly configured. We will now go through the steps to transform your Debian 11 system into a fully functional web server.

Update Software Packages and Install wget

Start by updating the system’s software package list. For this, open a terminal and run this command:

# sudo apt update

The next step is to install the wget utility that would enable you to download files within the terminal:

# sudo apt install wget -y

At this point, you are ready to install a LAMP stack and phpMyAdmin on your Debian system.

Install Apache

The first step in setting up a LAMP stack is installing the Apache web server. Apache uses an HTTP network to handle requests and send data. Run the following command in the terminal to install Apache on the system:

# sudo apt install apache2 -y

After installation, use the following command to ensure the Apache service is up and running.

# systemctl status apache2

systemctl status apache2

You can see a green status message letting you know that Apache is up and running. Use Ctrl+z to return to the terminal.

Install PHP on Debian 11

phpMyAdmin requires the PHP programming language and its environment for its operations. Run the following command to install the Apache and MySQL plugins, as well as the core PHP packages:

# sudo apt -y install php php-cgi php-mysqli php-pear php-mbstring libapache2-mod-php php-common php-phpseclib php-mysql

Once the installation is finished, print the PHP version information in the terminal with this command:

php --version

php --version

Install and Set Up MariaDB on Debian 11

The last component of the LAMP stack is a database. We will use MariaDB, an open-source relational database management system that interacts with MySQL. 

We will start by installing MariaDB with the following command:

# sudo apt install mariadb-server mariadb-client -y

Next, check the version information to verify if MariaDB is operational on the system:

# systemctl status mariadb

systemctl status mariadb

The green active (running) state indicates that the DB is installed and functioning. Next, the MariaDB database needs to be configured before you can install phpMyAdmin. 

Secure MariaDB

It’s essential to safeguard your MariaDB installation before installing phpMyAdmin on Debian. We recommend running the included security script by running this command in the terminal: 

# sudo mysql_secure_installation

Press Enter to bypass the first query as you haven’t yet entered a root password for your database settings.

Then, complete the following prompts:

Switch to unix_socket authentication [Y/n]: Enter n to skip.

Set root password? [Y/n]: Type y and press Enter to create a strong root password for your database. If you already have a root password, enter n to skip.

Remove anonymous users? [Y/n]: Type y and press Enter.

Disallow root login remotely? [Y/n]: Type y and press Enter.

Remove the test database and access it? [Y/n]: Type y and confirm with Enter.

Reload privilege tables now? [Y/n]: Type y and confirm with Enter.

Completing these steps will ensure that your MariaDB installation is secure.

cleaning up

Create a New MariaDB User

Next, you need to create a new MariaDB user. This user account will be used by phpMyAdmin to connect to your database. Creating a separate user enhances security and allows you to control the permissions granted to this user.

Step #2: Download phpMyAdmin

You can now download phpMyAdmin on your Debian machine.

Start by downloading the latest stable version of phpMyAdmin with the wget command:

# wget -P Downloads https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

If you prefer to download the English version only, modify the command as follows:

wget -P Downloads https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-english.tar.gz

The -P option instructs wget to save the files directly into the local Downloads directory. Alternatively, you can use any directory for the download; just remember the path for the next steps.

wget -P Downloads httpswww.phpmyadmin.netdownloadsphpMyAdmin-latest-english.tar.gz

Step 3: Check phpMyAdmin GPG Key

To ensure the integrity and authenticity of the downloaded phpMyAdmin archive, you need to verify its GPG key. Every archive has a matching .asc file with its own key signature in it. 

To confirm the GPG key, start by downloading the phpMyAdmin keyring to the directory you used for the archive download (The default location is the local Downloads directory):

# wget -P Downloads https://files.phpmyadmin.net/phpmyadmin.keyring

Navigate to the Downloads directory cd command and and import the keyring with this command: 

# gpg --import phpmyadmin.keyring

gpg --import phpmyadmin.keyring

By verifying the GPG key, you can ensure the downloaded phpMyAdmin files are authentic and have not been tampered with.

Download the corresponding GPG .asc file for your version of phpMyAdmin while staying in the same directory:

# wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz.asc

After the download finishes, verify the .asc file against the keyring you downloaded by running the following command in the same directory (in our case, Downloads):

# gpg --verify phpMyAdmin-latest-all-languages.tar.gz.asc

You can see the GPG key information, confirming the authenticity of the phpMyAdmin download.

gpg --verify phpMyAdmin-latest-all-languages.tar.gz.asc

Step 4: Unpack and Configure phpMyAdmin

Create a phpMyAdmin directory in the Apache web root directory with this mkdir command:

# sudo mkdir /var/www/html/phpMyAdmin

Access the Downloads directory and unpack the phpMyAdmin tar.gz files to the newly created directory:

# sudo tar xvf phpMyAdmin-latest-all-languages.tar.gz --strip-components=1 -C /var/www/html/phpMyAdmin

Note that the terminal will not show any response when the file is unpacked.

Create a default configuration file with the cp command:

# sudo cp /var/www/html/phpMyAdmin/config.sample.inc.php /var/www/html/phpMyAdmin/config.inc.php

Use the Nano text editor (or your preferred text editor) to add a secret passphrase to the config.inc.php file:

# sudo nano /var/www/html/phpMyAdmin/config.inc.php

Locate the following line in this file:

$cfg['blowfish_secret'] = '';

blowfish_secret

Add a strong secret passphrase within the quotes to secure your phpMyAdmin installation.

The line will look like this:

$cfg['blowfish_secret'] = 'passphrase';

Save and exit the file.

Next, remember to change the permissions for the config.inc.php file:

# sudo chmod 660 /var/www/html/phpMyAdmin/config.inc.php

Similarly, change ownership of the phpMyAdmin directory:

# sudo chown -R www-data:www-data /var/www/html/phpMyAdmin

You should restart the Apache service with the following command to apply the changes:

# sudo systemctl restart apache2

Step 5: Access phpMyAdmin in Browser

To access phpMyAdmin, open a web browser and navigate to the address where you installed phpMyAdmin. In our case, the address is:

localhost/phpMyAdmin

You should see the phpMyAdmin login screen, which indicates that the connection to the local Apache server, MariaDB, and PHP files has been successfully established.

phpmyadmin login window

Enter the username and password for the MariaDB user you established to access phpMyAdmin. 

Conclusion

You should now be well-versed in the process of installing phpMyAdmin on Debian 11 after following the instructions in this article. Using an easy-to-use online interface, this robust solution improves your capacity to administer MySQL and MariaDB databases. Don’t forget to safeguard your phpMyAdmin installation to prevent unwanted access to your data. With phpMyAdmin successfully installed on your Debian system, you can now efficiently handle your database administration tasks.

FAQs

Q. How do I secure my database servers when using phpMyAdmin?

To secure your database servers, ensure that you set a strong root user password during the MariaDB setup. Additionally, create a new user with limited privileges specifically for phpMyAdmin, and avoid using the root user for regular operations. Always keep your server and PHP installation up to date to protect against vulnerabilities.

Q. What PHP configuration is required for phpMyAdmin?

phpMyAdmin requires specific PHP modules such as php-mysqli, php-mbstring, and libapache2-mod-php to function correctly. Ensure these modules are installed and enabled in your PHP configuration. You can verify the installation by running php –version and checking the loaded modules.

Q. How do I access phpMyAdmin on my Debian server?

Once phpMyAdmin has been installed, open a web browser and type localhost/phpMyAdmin into the URL bar to access it. This will load the phpMyAdmin login screen where you can enter your admin username and password for a successful login.

Q. What steps should I take for server configuration to run phpMyAdmin efficiently?

Ensure that your Debian server is configured with the LAMP stack (Linux, Apache, MariaDB/MySQL, PHP). Adjust the PHP configuration to include necessary PHP modules and secure your MariaDB installation by setting a strong root password and creating users with appropriate privileges.

Q. Why is it important to configure a user with privileges for phpMyAdmin?

Configuring a user with specific privileges enhances security by limiting access to the database. This user should have only the necessary permissions required for phpMyAdmin operations, reducing the risk of unauthorized actions or data breaches.

Q. How can I verify my PHP installation is complete and compatible with phpMyAdmin?

After installing PHP, you can verify the installation by running php –version in the terminal. Additionally, check that all required PHP modules are installed by viewing your PHP configuration or using the php -m command to list the active modules.

Q. What should I do if I encounter issues logging into phpMyAdmin?

If you face login issues, ensure that you are using the correct admin username and password. Verify that your PHP configuration and database server are properly set up. Also, check the phpMyAdmin configuration file for any misconfiguration.

Q. Is it safe to use the default repository for phpMyAdmin installation on a Debian server?

While the default repository is generally safe, it might not always have the latest version of phpMyAdmin. For security reasons, it’s advisable to download the latest stable version directly from the phpMyAdmin website and verify its integrity using GPG keys.

Q. Why should I disable root login remotely for my database servers?

Disabling remote root login enhances security by preventing unauthorized access to your database servers. It’s a good practice to restrict root access to local connections only and use users with limited privileges for remote connections.

Q. What is a PHP application and how does phpMyAdmin fit this category?

A PHP application is a software program written in the PHP programming language. phpMyAdmin is a web-based application developed in PHP that provides a user-friendly interface to manage MySQL and MariaDB databases.

Q. How can developer cloud services benefit the setup of phpMyAdmin?

Developer cloud services offer scalable and flexible environments for deploying applications like phpMyAdmin. These services often provide easy server configuration, automated backups, and enhanced security features, making them ideal for developers managing databases.

Try this guide with our instant dedicated server for as low as 40 Euros