How to Install phpMyAdmin on a VPS: A Step-by-Step Guide for AnonVM

phpMyAdmin is a popular web-based tool for managing MySQL and MariaDB databases. It provides an easy-to-use interface for executing SQL queries, managing tables, and handling user permissions. This guide will walk you through installing phpMyAdmin on a Linux-based VPS, such as one hosted with AnonVM.


System Requirements

Ensure your server meets these requirements before installation:

  • OS: Ubuntu 20.04 or Debian 10/11
  • Web Server: Apache or Nginx
  • Database: MySQL or MariaDB
  • PHP: Version 7.4 or higher

Step 1: Update Your Server

Start by updating your package list and upgrading any outdated packages:

 
sudo apt update && sudo apt upgrade -y

Step 2: Install PHP and Required Modules

phpMyAdmin requires PHP along with certain extensions. Install them using:

 
sudo apt install php php-mbstring php-zip php-gd php-json php-curl -y

If you are using a different PHP version, adjust accordingly (e.g., php7.4 or php8.1).


Step 3: Install MySQL or MariaDB

phpMyAdmin works with both MySQL and MariaDB. If you haven’t installed a database yet, you can install MySQL with:

 
sudo apt install mysql-server -y

Secure the MySQL installation:

 
sudo mysql_secure_installation

Step 4: Install Apache (Optional)

If you don’t already have a web server installed, install Apache:

 
sudo apt install apache2 -y

Enable Apache to start at boot:

 
sudo systemctl enable apache2

If you’re using Nginx, ensure it is set up to work with PHP (instructions in the next steps).


Step 5: Install phpMyAdmin

  1. Install phpMyAdmin:
 
sudo apt install phpmyadmin -y

During installation, you’ll be prompted to select a web server to configure phpMyAdmin automatically. If you’re using Apache, select it here by pressing Space and Enter. For Nginx, you will manually configure it in a later step.

  1. Configure the Database: Choose Yes when prompted to allow phpMyAdmin to configure its own database.

  2. Set Up phpMyAdmin Password: Enter a strong password for the phpMyAdmin user when prompted. This password will be used by phpMyAdmin to access MySQL.


Step 6: Configure Apache or Nginx for phpMyAdmin

For Apache Users:

phpMyAdmin automatically configures itself with Apache if you selected it during installation. You can access phpMyAdmin by going to http://yourdomain.com/phpmyadmin.

For Nginx Users:

If you’re using Nginx, create a new server block for phpMyAdmin.

  1. Create a new Nginx configuration file:
 
sudo nano /etc/nginx/sites-available/phpmyadmin.conf
  1. Add the following configuration:
nginx
 
server { listen 80; server_name yourdomain.com; root /usr/share/phpmyadmin; index index.php index.html index.htm; location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { fastcgi_pass unix:/var/run/php/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|map|woff|ttf|svg|ico))$ { root /usr/share/; } } location /phpMyAdmin { rewrite ^/* /phpmyadmin last; } }
  1. Enable the phpMyAdmin configuration and restart Nginx:
 
sudo ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx

Step 7: Secure phpMyAdmin (Optional but Recommended)

  1. Restrict Access by IP Address: Limit access to phpMyAdmin by allowing only specific IP addresses. Add the following lines to your Nginx or Apache configuration:

    For Nginx:

    nginx
     
    location /phpmyadmin { allow your_ip_address; deny all; }
  2. Set Up Additional Authentication: Enable a basic HTTP authentication to add a layer of security.

  3. Enable HTTPS: Use Let’s Encrypt or another SSL provider to secure your phpMyAdmin installation over HTTPS.


Step 8: Log In to phpMyAdmin

Now that phpMyAdmin is set up, you can log in:

  1. Access phpMyAdmin: Open your browser and go to http://yourdomain.com/phpmyadmin.

  2. Log in using your MySQL root credentials or any other MySQL user credentials you have set up.

  3. Manage Databases: You should now see the phpMyAdmin dashboard, where you can create databases, run SQL queries, manage user permissions, and perform other database management tasks.


Conclusion

With phpMyAdmin installed on your AnonVM or similar VPS setup, you now have a powerful, web-based tool for managing databases. Remember to secure phpMyAdmin as much as possible by using HTTPS, restricting IP access, and adding authentication if needed. Regularly update phpMyAdmin, PHP, and your database server to maintain security and stability.

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution