How to Install phpMyAdmin on a CentOS 9 VPS or Dedicated Server

How to Install phpMyAdmin on a CentOS 9 VPS or Dedicated Server

phpMYAdmin is an excellent way to manage MariaDB or MySQL from within a browser. The intuitive graphical user interface allows you to create, edit and delete databases easily. You can even run queries without opening the terminal.

In this article, we’ll look at how to install phpMyAdmin on a CentOS 9 dedicated server or VPS. Read on to find out what you need.

What is phpMyAdmin?

phpMyAdmin is an open-source software tool that allows you to run and manage tables and other database operations from a browser. The tool supports various operations on MySQL and MariaDB.

Typical operations such as the management of tables, databases, indexes, permissions, and so on, are executed with the GUI. Administrators can also use phpMyAdmin to execute any SQL statement.

What is CentOS?

CentOS (or Community Enterprise Operating System) is an open-source project that consists of two distinct Linux distributions. In this article, we’ll be using CentOS Stream 9, which is the latest CentOS installation.

Released by enterprise software provider, Red Hat, on January 5th, 2022, CentOS is a stable operating system suitable for use by anyone from startups to large tech organizations.

What’s the Difference Between a VPS and a Dedicated Server?

A dedicated server is a type of hosting where you have an entire physical server to host your website. Since you don’t have to share the server’s resources, you enjoy high performance, high levels of security, and absolute control over the hardware and software of the server. Dedicated hosting is ideal if you require enhanced security, handle large amounts of web traffic every day, or operate a complex website within your own operating system.

A VPS (Virtual Private Server) on the other hand, is like a mix of shared and dedicated servers. But unlike any of them, a VPS hosts several clients on one server but uses virtualization technology to split it into multiple virtual servers, giving the users more control over the server. A VPS is best suited for organizations that have outgrown shared hosting but aren’t at the point of needing dedicated hosting yet.

Why You Need to Install phpMyAdmin in Your Centos 9 VPS or Dedicated Server

Many MySQL and MariaDB experts use phpMyAdmin and for good reasons. Here’s why you should use phpMyAdmin:

  • It supports and acts flexible for most of the commonly used formats. This is especially important when it comes to documentation.
  • Premium management operations at no extra cost from what you’ll spend owning the database management system.
  • It offers separate panels for database manipulation, status tracking, and SQL query editing.

Requirements

Before you install phpMyAdmin on your CentOS 9 dedicated server or VPS, ensure you have the following requirements:

  • A VPS plan running CentOS Stream 9 server.
  • A non-root user access with sudo privileges.
  • MySQL server.
  • Apache web server.
  • PHP scripting language.
Note
Note: This guide is for installing phpMyadmin 5.x. Installing earlier versions of phpMyAdmin might be slightly different.

Step 1: Update Your System

Before you install phpMyAdmin on the CentOS 9 server, update your system with the command below:

yum update –y

Step 2: Check Whether MariaDB or MySQL Is Working

Next, run the commands below to check if the database management system is working.

If you have MariaDB installed:

systemctl status mariadb

If you have MySQL installed:

systemctl status mysql

You should see an active status in green (as seen below) if the services are working.

In case you don’t have a database management system installed, run the command below to install MariaDB:

yum -y install mariadb-server mariadb

Now start MariaDB and check if it’s running with the following commands:

systemctl start mariadb
systemctl status mariadb

Then, you can enable startup with the following command:

systemctl enable mariadb

Since MariaDB is not secure, we can secure it with the following command:

Mysql_secure_installation

This will help us in setting a root password and in removing anonymous users and test databases.

Step 3: Installing EPEL Repository

To install phpMyAdmin, we need the EPEL repo. Follow the steps below to install it.

First, que launch the following commands:

dnf config-manager --set-enabled crb
dnf install epel-release epel-next-release -y

We can check if the repo is installed with the following command:

dnf repolist

Step 4: Install phpMyAdmin

With the steps above out of the way, you can now install phpMyAdmin with the following command:

dnf install phpMyAdmin –y

Next, you need to edit the phpMyAdmin configuration file using your favorite editor (we will use vi)

We’ll add the “Require all granted” value just under the ‘usr/share/phpMyAdmin/ directory.

Edit the file with vi:

vi /etc/httpd/conf.d/phpMyAdmin.conf

With the down key cursor, go to the line <Directory /usr/share/phpMyAdmin/>

And press the key “o”

Now paste the following content:

Require all granted

Then press ESC to exit edit mode, and 😡 to save changes and exit.

Alternatively, you can just execute the following command to do it automatically:

sed -i '/^<Directory /usr/share/phpMyAdmin/>/a Require all granted' /etc/httpd/conf.d/phpMyAdmin.conf

Now we’re going to start the Apache service with the command below:

systemctl restart httpd

We can also use the command below to check if the service has started correctly:

Systemctl status httpd

You can now visit the website below to test the installation:

http://ip_adress/phpmyadmin

Where IP_address is the IP of your server which can be obtained with the following command:

hostname –I

If the installation was successful, you should see the phpMyAdmin login page as seen below. Enter your username and password and click ‘Go’ to login.

That’s it! You’ve successfully installed phpMyAdmin on your CentOS 9 VPS or dedicated server.

Remember, you need to log in with your root password if you haven’t added any user on your MariaDB/MySQL database. Once you logged in, you will be able to manage your database and run MySQL queries from an intuitive interface that is far much easier than using the MySQL command line interface.

How About if You Want to Do It All in One Go?

You can use the following script to do it

Edit a file called installphpmyadmin.sh, like we did with vi, with the following content:

#!/bin/bash
yum -y update;
if (rpm -q mariadb) || (rpm -q mysql); then
  echo "DB Server already installed";
else
  echo "Installing MariaDB";
  yum install mariadb-server mariadb -y;
  echo "Starting mariadb server";
  systemctl start mariadb;
  systemctl status mariadb;
  systemctl enable mariadb;
  echo "Launching mysql_secure_installation unnatended, the root password will be hostadvice.com";
  sed -e 's/s*([+0-9a-zA-Z]*).*/1/' << EOF | mysql_secure_installation
      # current root password (emtpy after installation)
    y # Set root password?
    hostadvice.com # new root password
    hostadvice.com # new root password
    y # Remove anonymous users?
    y # Disallow root login remotely?
    y # Remove test database and access to it?
    y # Reload privilege tables now?
EOF
fi
if (rpm -q httpd); then
  echo "Apache server already installed";
else
  echo "Installing apache server";
  dnf -y install httpd;
fi;
if (rpm -q php); then
  echo "php already installed";
  if (rpm -q php-mysqlnd); then
    echo "php-mysqlnd already installed";
  else
    echo "Installing php-mysqlnd";
    dnf install mysqlnd -y;
  fi;
else
  echo "Installing php and php-mysqlnd";
  dnf install php php-mysqlnd -y;
fi;
if ! (dnf repolist|grep -qi epel); then
  echo "Installing EPEL repo";
  dnf config-manager --set-enabled crb;
  dnf install epel-release epel-next-release -y;
  dnf repolist|grep --color=auto -i epel;
else
  echo "EPEL repo already installed";
fi
echo "Installing phpMyAdmin";
dnf -y install phpMyAdmin;
sed -i '/^<Directory /usr/share/phpMyAdmin/>/a Require all granted' /etc/httpd/conf.d/phpMyAdmin.conf;
ipaddress=$(hostname -I);
echo "Server IP address: $ipaddress";
echo "Checking phpmyadmin access:..."
if [[ `curl --write-out \n%{http_code} --silent --output /dev/null $ipaddress/phpMyAdmin` =~ [^(2|3).*] ]]; then
  echo OK;
else
  echo "Not OK";
fi

This will update the server. Install Apache, PHP, MySQL, and phpMyAdmin if needed.

Note
Note: The default root password for MySQL will be “hostadvice.com”

Save the file, and make it executable with the command below:

chmod 700 ./installphpmyadmin.sh

And execute it:

./installphpmyadmin.sh

There you have it! Those are two easy ways of installing phpMyAdmin on a CentOS 9 VPS or dedicated server.

Conclusion

phpMyAdmin is a great tool and we’d recommend anyone who uses MySQL or MariaDB regularly to install it. Hopefully, this is an easy task with the tutorial above.

That said, if you’re still using CentOS 7, you can read our tutorial on how to install phpMyAdmin on a CentOS 7 VPS or dedicated server.

Next Steps: What Now?

There are a few key takeaways we can get from this article:

  • You can use phpMyAdmin to manage tables, databases, indexes, permissions, and other database operations from a browser.
  • A dedicated server is ideal for advanced websites receiving lots of traffic, while a VPS is ideal for organizations that have outgrown shared hosting but still can’t afford dedicated hosting.
  • Before you install phpMyAdmin on a CentOS 9 server, you have to update the system.
  • You need to log in to phpMyAdmin with your root password if you haven’t added any user to your MariaDB/MySQL database.

Further Reading

If you found this guide helpful, you should definitely check out the following articles to learn more about the subject of installing phpMyAdmin on a CentOS 9 server.

  1. How to Set up a Virtual Private Server (VPS) in 5 Steps
  2. How to Install MYSQL 8.0 and Create a Database on an Ubuntu 22.04 Linux VPS
  3. How to Recover a Hacked Server
  4. How to Install and Configure MySQL on a Windows Server 2022
  5. How to install MySQL 8 Database on CentOS 8

FAQ

Did we miss something? Here are some of the most frequently asked questions on how to install phpMyAdmin on a CentOS 9 VPS or dedicated server:

What Are the Disadvantages of Using phpMyAdmin?

Although phpMyAdmin is a stellar tool, it has its fair share of shortcomings. Here are some of the downsides of using phpMyAdmin:

  • It cannot be used for any and all databases, it only supports MariaDB and MySQL.
  • Although it supports traditional systems and servers, its growth is not at par with current technology industry standards.

Why Should You Use CentOS?

CentOS stream is an excellent server operating system used by many professionals. Here are some of the reasons you should use CentOS:

  • Security: Privacy and security are paramount in the modern world. CentOS has numerous built-in security features that keep your data safe from cyberattacks. One of the main ways CentOS promotes security is by utilizing Security Enhanced Linux (SELinux), an access control mechanism that enforces rules on processes and files based on policies you define.
  • A wealth of documentation: Since CentOS is a widely used platform, it has become an industry standard. As a result, there’s tons of information available for it. There’s a broad community of developers that shares intelligence and other issues regularly, increasing its overall value as an operating system.
  • Guaranteed support: One of the most important things developers look for in an operating system is support for the platform. Redhat, the organization behind CentOS offers regular support and updates for the CentOS Stream.
  • Package management: If you have a project in production and you’d not like it to change, or have the packages updated when you need to run specific versions, CentOS uses the Yellowdog Update Modifier (YUM) package manager to keep the system up-to-date.
  • Management panel support: Finally, CentOS can support multiple management platforms including InterWorx, cPanel, CWP, Spacewalk, DirectAdmin, Webmin, VestaCP, and many more. These panels make it easy to run multiple sites on your server keeping all the core server procedures and processes well-managed.

Do I need a VPS?

A Virtual Private Server is the transitional phase between shared hosting and having a dedicated server. Your business needs a VPS if:

  • Your website starts outgrowing the resources and scalability: If your website needs more traffic and resource scalability than you can get from shared hosting, you can try a VPS. VPS servers are suitable for corporate pages, online shops, and enterprise apps.
  • You want more control: Shared hosting restricts you on so many levels. For instance, if you’re working on a project that requires specific software, it’s best to get a VPS.

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How To Set up a VSFTPD Server on an Ubuntu 16.04 VPS or Dedicated Server

Brief Description FTP data is usually insecure since information (usernames, pa
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to use phpMyAdmin to develop a website (without MySQL experience)

Brief description A web developer who is not well versed into coding websites f
2 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Install MySQL on a Windows Web Server Running Apache

This tutorial will show you how to install the MySQL database on a Windows serve
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top