How To Install phpMyAdmin on Ubuntu 22.04
PhpMyAdmin is a free and open source administration tool for MySQL and MariaDB. It's an excellent tool for browsing, editing, creating, and dropping tables, as well as modifying columns and data. You don't need to login into execute any query from the MySQL command line. As a portable web application written primarily in PHP, it has become one of the most popular MySQL administration tools, especially for web hosting services.
Step 1 – Install Apache and PHP
We are assuming you already have installed the MySQL server on Ubuntu system if you haven't then install from here So just install the other required packages to run and access phpMyAdmin.
[root@hackthesec ~]#
sudo apt install apache2 wget unzip
[root@hackthesec ~]#
sudo apt install php php-zip php-json php-mbstring php-mysql
Once the installation is finished, enable and start the Apache web server.
[root@hackthesec ~]#
sudo systemctl enable apache2
[root@hackthesec ~]#
sudo systemctl start apache2
You can quickly install the phpMyAdmin from the default Ubuntu repositories. But they contain an older version of phpMyAdmin. you can install the older using this command apt install phpMyAdmin, but to install the latest version, you need to download it from the official website.
Download the latest phpMyAdmin archive from the official download page.
[root@hackthesec ~]# wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip
[root@hackthesec ~]# unzip phpMyAdmin-5.2.0-all-languages.zip
[root@hackthesec ~]# sudo mv phpMyAdmin-5.2.0-all-languages /usr/share/phpmyadmin
[root@hackthesec ~]#
sudo mkdir /usr/share/phpmyadmin/tmp
[root@hackthesec ~]# sudo chown -R www-data:www-data /usr/share/phpmyadmin
[root@hackthesec ~]#sudo chmod 777 /usr/share/phpmyadmin/tmp
[root@hackthesec ~]# sudo nano /etc/apache2/conf-available/phpmyadmin.conf
add the below content to the file.
Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
<RequireAny>
Require all granted
</RequireAny>
</IfModule>
</Directory>
<Directory /usr/share/phpmyadmin/setup/>
<IfModule mod_authz_core.c>
<RequireAny>
Require all granted
</RequireAny>
</IfModule>
</Directory>
Save and exit after that reload or restart the apache2 once using below command also you have to enable the newly created config file
[root@hackthesec ~]# sudo a2enconf phpmyadmin
[root@hackthesec ~]# sudo systemctl restart apache2
Step 4 – Adjusting FirewallD
The systems with enabled firewalls need to allow HTTP service from the firewall. Run the below commands to open a port for the webserver in the firewall.
[root@hackthesec ~]# sudo firewall-cmd --permanent --add-service=http
[root@hackthesec ~]# sudo firewall-cmd --reload
Step 5 – Create a MySQL Database and User
Connect to the MySQL server running on your system.
[root@hackthesec ~]# mysql
If you already setup the root password for mysql then you have to use
[root@hackthesec ~]# mysql -uroot -p
Execute the following MySQL queries one by one to create a database and user. Also, assign the privileges to the user on the database.
mysql> CREATE DATABASE hackthesec;
Query OK, 1 row affected (0.01 sec)
mysql> CREATE USER 'hackthesec'@'localhost' IDENTIFIED BY 'Strong@password';
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT ALL ON hackthesec.* TO 'hackthesec'@'localhost';
Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
Step 6 – Access phpMyAdmin
All done. You have finished the setup with the phpMyAdmin on the Ubuntu Linux system. Now access phpMyAdmin with the server IP address or domain name.
http://your-server-ip-domain/phpmyadmin
0 comments:
Post a Comment