Introduction
The phpMyAdmin utility is a graphical database management tool. By installing phpMyAdmin, you no longer need to use a default command-line interface to manage your databases.
PhpMyAdmin is a web-based application and requires the LAMP stack to work properly. This guide shows you how to lay the groundwork and install phpMyAdmin on Debian 10.
Prerequisites
- Debian 10 (Buster) installed and running
- A user account with sudo or root privileges
- Access to a terminal window/command line
Step 1: Install LAMP Stack on Debian 10
You need a functioning web server for phpMyAdmin to work properly. This section shows you how to install the supporting software to turn your Debian 10 system into a web server.
If you already have a LAMP stack installed, you can skip directly to the Download phpMyAdmin section.
Step 1.1: Update Software Packages and Install wget
Access your terminal window, and update your software package lists using the following command:
sudo apt update
Installing outdated software packages is a severe security liability. Do not skip this step.
The wget utility allows you to download files directly from the terminal window. Enter the following command to install the wget tool:
sudo apt install wget -y
You now have the tools you need to install a LAMP stack and phpMyAdmin.
Step 1.2: Install Apache
Apache is the webserver software that processes requests and transmits data over an HTTP network. Open a terminal window, and install Apache by entering the following command:
sudo apt install apache2 -y
The process can take a few moments to complete. Enter the following command to make sure the Apache service is running:
systemctl status apache2
In the report that follows, you should see a green status that says active (running).
Press Ctrl+z
to return to the command prompt.
Step 1.3: Install PHP on Debian 10
The PHP programming language and coding environment is essential for running a web application like phpMyAdmin. Install core PHP packages and Apache and MySQL plugins with the following command:
sudo apt install php php-cgi php-mysqli php-pear php-mbstring php-gettext libapache2-mod-php php-common php-phpseclib php-mysql -y
Once the installation process is complete, verify that PHP has been installed:
php --version
The system displays the current version of PHP, along with the date of the release.
Step 1.4: Install and Set Up MariaDB on Debian 10
This guide uses the MariaDB open-source relational database management system instead of MySQL. MariaDB and MySQL are compatible, and many of the commands and features are identical.
To install MariaDB, enter the following command into your terminal:
sudo apt install mariadb-server mariadb-client -y
Once the process is complete, verify the MariaDB installation with the following command:
systemctl status mariadb
Like with Apache, you see an active (running) status.
Before installing phpMyAdmin, you need to configure the MariaDB database.
Secure MariaDB
Configure basic MariaDB security features by launching a built-in script:
sudo mysql_secure_installation
As you have not yet set a root password for your database, hit Enter to skip the initial query. You are now presented with the following options:
- Set root password? [Y/n] – Type
y
and press Enter to create a strong root password for your database. - Remove anonymous users? [Y/n] – Type
y
and press Enter. - Disallow root login remotely? [Y/n] – Type
y
and press Enter. - Remove test database and access to it? [Y/n] – Type
y
and confirm with Enter. - Reload privilege tables now? [Y/n] – Type
y
and confirm with Enter.
The output confirms that your MariaDB installation is now secure.
Create a New MariaDB User
The phpMyAdmin utility needs a designated user to be able to connect to your database. Creating a new MariaDB user improves security and allows you to control the level of permissions granted to this user.
Use our detailed guide to create a new MariaDB user and grant privileges. Once you have set up a MariaDB user, you are ready to start the phpMyAdmin installation process.
Step 2: Download phpMyAdmin
Use the wget
command to retrieve the latest stable version of phpMyAdmin:
wget -P Downloads https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
The -P
option instructs wget
to save the files directly in the Downloads directory. Feel free to specify any directory you see fit.
Note: At the time of writing this article, the latest version is phpMyAdmin 5.0.2. For a specific version, or to check the latest version, please see the developer’s download page.
Step 3: Check phpMyAdmin GPG Key
Each downloaded archive has a corresponding .asc file that contains its unique key signature. Once both files are in the same folder, the signature can be verified.
- To verify the GPG key for phpMyAdmin, download the phpMyAdmin keyring to the Downloads directory:
wget -P Downloads https://files.phpmyadmin.net/phpmyadmin.keyring
- Access the Downloads directory and import the keyring:
cd Downloads
gpg --import phpmyadmin.keyring
- Download the corresponding GPG .asc file for your version of phpMyAdmin:
wget -P Downloads https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz.asc
- Access the Downloads directory and verify the .asc file against the keyring you downloaded:
cd Downloads
gpg --verify phpMyAdmin-latest-all-languages.tar.gz.asc
The system responds by displaying GPG key information.
You can now compare the GPG key to the developer credentials on the documentation page.
Step 4: Unpack and Configure phpMyAdmin
- Create a phpMyAdmin directory in the Apache web root directory:
sudo mkdir /var/www/html/phpMyAdmin
- Access the Downloads directory and unpack the phpMyAdmin tar.gz files to the newly created directory:
cd Downloads
sudo tar xvf phpMyAdmin-latest-all-languages.tar.gz --strip-components=1 -C /var/www/html/phpmyadmin
- Create a default configuration file:
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:
$cfg['blowfish_secret'] = '';
Add a secret passphrase as follows:
$cfg['blowfish_secret'] = 'my_secret_passphrase';
Use a complex passphrase of your choice and then exit and save the file (Ctrl+x
).
- Change the permissions for the config.inc.phpfile:
sudo chmod 660 /var/www/html/phpmyadmin/config.inc.php
- Change ownership of the phpmyadmindirectory:
sudo chown -R www-data:www-data /var/www/html/phpmyadmin
- Restart Apache:
sudo systemctl restart apache2
Step 5: Access phpMyAdmin from Browser
Use your preferred web browser and navigate to the following web address:
localhost/phpmyadmin
The system prompts the phpMyAdmin login screen and establishes a connection to the local Apache, MariaDB, and PHP files that you have created.
Log in to phpMyAdmin with the username and password for the MariaDB user you had created and granted privileges to.
Take your time and explore the many options and settings phpMyAdmin has to offer.
Conclusion
You have now installed phpMyAdmin on your Debian 10 system. Access the graphical user interface from your browser and start administering your databases more efficiently.
原创文章,作者:1402239773,如若转载,请注明出处:https://blog.ytso.com/224193.html