How To Install and Secure phpMyAdmin on Ubuntu

Installing and securing phpMyAdmin on Ubuntu involves a few key steps: installing phpMyAdmin, configuring it to work with your existing web server and database, and securing access to the application. Here's a step-by-step guide on how to achieve this:

Step 1: Update Package Lists

Before you begin, make sure your package lists are up to date:

        
            sudo apt update
        
    

Step 2: Install phpMyAdmin

To install phpMyAdmin, run the following command:

        
            sudo apt install phpmyadmin
        
    

During the installation, you will be prompted to choose the web server to configure. If you're using Apache, select it using the spacebar and hit Enter.

You'll then be prompted to configure the database. Select "Yes" to allow dbconfig-common to configure the database for phpMyAdmin.

When prompted, enter the MySQL root password and then create a password for the phpMyAdmin application user.

Step 3: Configure Apache

If you are using Apache and did not select it during the installation prompts, you will need to manually enable the phpMyAdmin configuration:

        
            sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
        
    

Then, restart Apache for the changes to take effect:

        
            sudo systemctl restart apache2
        
    

Step 4: Secure phpMyAdmin

  1. Restrict Access: Limit access to phpMyAdmin by configuring Apache. Create a configuration file for phpMyAdmin:

                    
                        sudo nano /etc/apache2/conf-available/phpmyadmin.conf
                    
                

    Inside the file, find the <Directory /usr/share/phpmyadmin/> section and add IP address restrictions:

                    
                        <Directory /usr/share/phpmyadmin/>
                            Options SymLinksIfOwnerMatch
                            DirectoryIndex index.php
                            AllowOverride All
                            Require ip 127.0.0.1 ::1
                            Require ip YOUR.IP.ADDRESS.HERE
                        </Directory>                
                    
                

    Replace YOUR.IP.ADDRESS.HERE with the IP address from which you want to allow access.

    Save and exit the file, then restart Apache:

  2. Secure Your MySQL Database: Make sure your MySQL server is secure. Run the following command to secure MySQL:

                    
                        sudo mysql_secure_installation
                    
                

    Follow the prompts to improve security, such as setting a strong root password and removing anonymous users.

  3. Use HTTPS: If you haven’t already, set up HTTPS for your web server. This helps secure the data transmitted to and from phpMyAdmin.
  4. Use Strong Authentication: When you log in to phpMyAdmin, make sure to use a strong password for your MySQL user accounts.

Step 5: Access phpMyAdmin

You can now access phpMyAdmin in your web browser:

  • Visit http://your_server_ip/phpmyadmin (or https://your_server_ip/phpmyadmin if you're using HTTPS).
  • Log in using your MySQL credentials.
Final Steps
  • Keep Software Updated: Regularly update phpMyAdmin and other related software to ensure security.
  • Backups: Regularly back up your database and server configuration.

Following these steps should help you install and secure phpMyAdmin on Ubuntu, ensuring a safe and efficient setup.

How To Set Up an Ubuntu Server on a DigitalOcean Droplet

Setting up an Ubuntu Server on a DigitalOcean Droplet is a common task for deploying web applications, hosting websites, running databases, and more. Here's a detailed guide to help you through the process. Setting up an Ubuntu server on a DigitalOce …

read more

How to Install DigitalOcean Spaces for WordPress Solutions

To integrate DigitalOcean Spaces with WordPress, you'll typically use a plugin that enables you to offload media files (such as images, videos, etc.) to Spaces instead of storing them on your WordPress server. you can integrate DigitalOcean Spaces wi …

read more