Step 1 – Install Apache and PHP
$ sudo apt install apache2 wget unzip
$ sudo apt install php php-zip php-json php-mbstring php-mysql
Once the installation is finished, enable and start the Apache web server.
$ sudo systemctl enable apache2
$ sudo systemctl start apache2
Step 2 – Install phpMyAdmin on Ubuntu 22.04
$ wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip
$ unzip phpMyAdmin-5.2.0-all-languages.zip
$ sudo mv phpMyAdmin-5.2.0-all-languages /usr/share/phpmyadmin
Next, create tmp directory and set the proper permissions. This is a necessary step to make it work properly.
$ sudo mkdir /usr/share/phpmyadmin/tmp
$ sudo chown -R www-data:www-data /usr/share/phpmyadmin
$ sudo chmod 777 /usr/share/phpmyadmin/tmp
Step 3 – Configure phpMyAdmin
Now, you need to configure the web server to serve phpMyAdmin on the network. Create an Apache configuration file for phpMyAdmin and edit it in a text editor:
$ 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>
After making all the changes, make sure to start the Apache service to reload all settings.
$ sudo a2enconf phpmyadmin
$ 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.
$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --reload
If you don't have firewall installed, run:
$ sudo apt-get firewall
apt-get install libapache2-mod-php
. There are some other library pacakges likephp-gd
orphp-mbstring
that you might need, but they might be pulled in automatically when you install libapache2-mod-php, so give that a try and let me know what happens next. – Redundancy