Install PHPmyadmin Apache2 and MySQL on Ubuntu 22.04


In this tutorial, you will learn how to install and configure phpmyadmin Apache 2 and MySQL on Ubuntu 22.04 server.

This tutorial will show you steps by step guide on how to install phpMyAdmin, Apache2, and MySQL on your Ubuntu 22.04 server to manage your MySQL databases using the user-friendly web interface provided by phpMyAdmin.

How to Install phpMyAdmin, Apache 2, and MySQL on Ubuntu 22.04

Steps to install and configure phpmyadmin apache 2 and MySQL on Ubuntu 22.04 server.

  • Step 1 – Update System Dependencies
  • Step 2 – Install and Configure Apache 2
  • Step 3 – Install and Configure MySQL
  • Step 4 – Install and Configure PhpMyAdmin

Step 1 – Update System Dependencies

First of all, open your terminal or command line and execute the following commands into it to update the packages to the latest version available:

sudo apt update
sudo apt upgrade

Step 2 – Install and Configure Apache 2

Next, execute the following command on command line or terminal to install apache 2 on ubuntu 22.04 system:

sudo apt install apache2

Once the Apache 2 installation has been finished. Now, you need to set up Uncomplicated Firewall (UFW) with Apache 2 to allow public access on default web ports for HTTP and HTTPS

sudo ufw app list

Then you will see all the listed applications.

Output
Available applications:
Apache
Apache Full
Apache Secure
OpenSSH
  • Apache: This profile opens port 80 (normal, unencrypted web traffic)
  • Apache Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
  • Apache Secure: This profile opens only port 443 (TLS/SSL encrypted traffic)
  • OpenSSH: This profile opens port 22 for SSH access.

If you are not going to use SSL, so you need to enable only the Apache profile. By using the following command, you can enable apache full on ubuntu server:

sudo ufw allow 'Apache Full'

Every process in Apache is managed with the systemctl command. Check the status of Apache 2 with the following command.

sudo systemctl status apache2
Output
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2023-04-29 00:34:49 UTC; 2min 52s ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 12782 (apache2)
      Tasks: 55 (limit: 1151)
     Memory: 5.1M
        CPU: 52ms
     CGroup: /system.slice/apache2.service
             ├─12782 /usr/sbin/apache2 -k start
             ├─12784 /usr/sbin/apache2 -k start
             └─12785 /usr/sbin/apache2 -k start

Step 3 – Install and Configure MySQL

Once you have installed Apache 2 on Ubuntu server. Next, you need to install and configure mysql on ubuntu 22.04.

So, execute the following command on the terminal or command line to install MySQL server on ubuntu server with Apache 2:

sudo apt install mysql-server

During the installation process, you’ll be prompted to set a password for the MySQL root user. Make sure to choose a strong password and remember it.

To secure your MySQL installation, execute the following command and follow the prompts:

sudo mysql_secure_installation

Once you have executed this command. Then the questions given below in the prompt will appear:

  • You will be presented with a screen where MySQL asks whether you would like to activate the VALIDATE PASSWORD PLUGIN. For now, keeping things simple, type no.
  • In the next type the root password of your choice. Confirm it again.
  • In the next screen MySql will ask whether to remove anonymous users. Type yes
  • Disallow root login remotely? Type No
  • Remove test database and access to it? Type Yes
  • Reload privilege tables now? Type Yes

If you want to check whether MySQL is working correctly by logging into the database, so you can execute the following command on terminal:

sudo mysql -u root -p

This command will ask for the password. Please Enter the password that you enter while securing the MySQL and hit enter will log in into MySQL:

Now, Type exit on ssh terminal to get out of MySql:

exit

Step 4 – Install and Configure PhpMyAdmin

Execute the following command on the terminal or command line to install PHPmyadmin on the ubuntu apache 2 server:

sudo apt install phpmyadmin

During the installation process, you’ll be prompted to choose a web server. Select apache2 and press Enter.

You’ll also be asked if you want to configure the database for phpmyadmin with dbconfig-common. Choose Yes.

Next, you’ll be prompted to set a password for the phpMyAdmin database user. This should be a separate password from the MySQL root password. Choose a strong password and remember it.

By default, phpMyAdmin is not accessible from the web. We’ll create a symbolic link for phpMyAdmin in the Apache web directory to make it accessible.

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
sudo systemctl reload apache2

Next, execute the following command on the terminal to login into your MySQL server:

sudo mysql -u root -p

Next, execute the following query on the terminal to allow root access login into your MySQL using PHPMyAdmin:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Note that, Replace the password with the root password you entered while installing MySql.

Next, execute the following query to flush privileges for your root user:

FLUSH PRIVILEGES;

Finally, Execute the following command on the terminal to restart Apache 2 server:

sudo service apache2 restart

Conclusion

Congratulations! You have successfully installed phpMyAdmin, Apache2, and MySQL on your Ubuntu 22.04 server. You can now efficiently manage your MySQL databases using the user-friendly web interface provided by phpMyAdmin.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?