phpMyAdmin is a popular open-source tool that allows you to manage MySQL or MariaDB databases using a web interface. It simplifies database management by providing a user-friendly GUI for tasks like creating databases, running queries, and managing users. This guide will walk you through installing phpMyAdmin on Ubuntu 22.04. Whether you're managing databases locally or on a Windows VPS UK, phpMyAdmin will help streamline your database operations.
Step 1: Update Your System
Before installing phpMyAdmin, ensure that your system is up to date. Run the following commands to update your package list and upgrade installed packages:
sudo apt update && sudo apt upgrade -y
Keeping your system up to date is critical for security and performance, especially when managing a server on platforms like VPS Windows Servers.
Step 2: Install Apache, MySQL, and PHP
If you haven’t already installed the LAMP (Linux, Apache, MySQL, PHP) stack, you need to do so first. Install Apache, MySQL, and PHP along with the necessary PHP extensions for phpMyAdmin:
sudo apt install apache2 mysql-server php libapache2-mod-php php-mbstring php-zip php-gd php-json php-curl -y
Start and enable Apache and MySQL to run at boot:
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl start mysql
sudo systemctl enable mysql
Step 3: Install phpMyAdmin
phpMyAdmin is available in the default Ubuntu repository. Install it using the following command:
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl -y
During the installation, you will be prompted to select the web server that should be automatically configured to run phpMyAdmin. Select apache2 using the spacebar and press Enter.
Next, you’ll be prompted to configure the phpMyAdmin database. Choose Yes and then set a password for the phpMyAdmin application.
Step 4: Enable PHP Extensions
Enable the required PHP extensions for phpMyAdmin to function properly:
sudo phpenmod mbstring
Restart Apache to apply the changes:
sudo systemctl restart apache2
Step 5: Configure phpMyAdmin
phpMyAdmin is now installed, but you need to configure MySQL to allow phpMyAdmin to manage databases. Log in to MySQL:
sudo mysql -u root -p
Create a new MySQL user and grant it the necessary privileges:
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
Replace your_password
with a secure password of your choice.
Step 6: Access phpMyAdmin
You can now access phpMyAdmin by navigating to http://your_server_ip/phpmyadmin
in your web browser. Use the MySQL credentials you created earlier to log in.
If you’re running this setup on a Windows VPS UK server, phpMyAdmin will provide a reliable interface for managing databases from anywhere.
Step 7: Secure phpMyAdmin (Optional)
phpMyAdmin is a powerful tool, but it can be a target for attacks if not properly secured. One way to add security is by setting up an additional authentication layer using Apache.
First, create a password file using the htpasswd
utility:
sudo htpasswd -c /etc/phpmyadmin/.htpasswd your_username
After creating the password file, edit the phpMyAdmin Apache configuration file:
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
Add the following lines to the configuration file to enable basic authentication:
<Directory /usr/share/phpmyadmin>
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user
</Directory>
Save and close the file, then restart Apache to apply the changes:
sudo systemctl restart apache2
Now, when you access phpMyAdmin, you will be prompted to enter the additional username and password before accessing the login page.