How to Install phpMyAdmin on FreeBSD 12

|
Last Updated:
|
|
install phpmyadmin on freebsd

This guides presents a simple way on how to install phpMyAdmin on FreeBSD 12. phpMyAdmin is a free and opensource tool written in PHP for managing MySQL and MariaDB tasks such as creating, altering, dropping, deleting database tables or running any other database management commands over the web interface.

phpMyAdmin comes bundled with a handful features which you can check them from here.

Installing phpMyAdmin on FreeBSD 12

Prerequisites

Install FEMB/FAMB Stack

In order to use phpMyAdmin, you need to have a FAMB or FEMB Stack installed on your FreeBSD 12 server.

Install FEMP Stack on FreeBSD 12

Install FAMB Stack on FreeBSD 12

Install Required PHP Modules

Install the required PHP extensions if you have not done so already;

pkg install php82-session php82-mbstring php82-mysqli wget curl php82-filter

You can verify the presence of the above PHP extensions by running the command below;

php -m | egrep "json|mbstring|session|mysqli|hash|filter"
hash
json
mbstring
mysqli
session
filter

If not enabled by default, edit the /usr/local/etc/php.ini and add the following lines to load the extensions installed above.

vi /usr/local/etc/php.ini
extension=mysqli.so
extension=mbstring.so
extension=json.so
extension=session.so
extension=filter.so

Save and quit the file.

Restart Apache and confirm again using php -m command.

service apache24 restart

Assuming you have FAMB/FEMB Stack with the necessary PHP extensions up and running, proceed as follows;

Note, we are using FAMB in this guide.

Download phpMyAdmin package

In order to get the latest version of phpMyAdmin running on your server, navigate to the download page and grab the latest package of phpMyAdmin. Even though phpMyAdmin is usually included in most systems default repositories, they may not be up-to-date. You can however check the same to verify.

To install phpMyAdmin from the source, you can simply run the command below to download the current release version 5.2.1.

Replace the value of the VER variable below with the current release version of phpMyAdmin;

set VER=5.2.1
wget https://files.phpmyadmin.net/phpMyAdmin/$VER/phpMyAdmin-$VER-english.zip

Verify Integrity of phpMyAdmin Package

Verify that the downloaded file is not corrupted by comparing that SHA256 hash for the two files matches.

From the phpMyAdmin download page, download the SHA256 file for the phpMyAdmin-$VER-english.zip into the same directory where phpMyAdmin package is;

wget https://files.phpmyadmin.net/phpMyAdmin/$VER/phpMyAdmin-$VER-english.zip.sha256

To check the SHA256 for the downloaded file, run the command below;

sha256sum -c phpMyAdmin-$VER-english.zip.sha256

Output;

phpMyAdmin-5.2.1-english.zip: OK

Great, the hashes match and we are good to proceed.

The output will indicate whether the hash values match or not. If the hash values match, you will see a message indicating that the file is OK. If the hash values do not match, you will see an error message indicating that the file has failed the integrity check.

Install phpMyAdmin on FreeBSD 12

Unzip the phpMyAdmin package downloaded above and move it to Apache Web Root directory, /usr/local/www/apache24/data.

unzip phpMyAdmin-$VER-english.zip
mv phpMyAdmin-$VER-english /usr/local/www/apache24/data/phpmyadmin

CONFIGURE PHPMYADMIN

phpMyAdmin has been installed and thus can be configured as follows;

Navigate to the /usr/local/www/apache24/data/phpmyadmin and rename the PHP configuration file.

cd /usr/local/www/apache24/data/phpmyadmin
cp config{.sample,}.inc.php

Create a tmp folder for caching templates and set proper permissions;

mkdir /usr/local/www/apache24/data/phpmyadmin/tmp
chmod 755 /usr/local/www/apache24/data/phpmyadmin/tmp
chown -R www:www /usr/local/www/apache24/data/phpmyadmin/tmp

Create a blowfish secret required for cookie based authentication to encrypt password in cookie. The secret needs to be a 32-bytes long string of random bytes.

You can generate the secret;

openssl rand -hex 16
8e41a8be54813c6b8f34b0fe6ebb5edb

and paste as follows;

vi /usr/local/www/apache24/data/phpmyadmin/config.inc.php
...
/**
 * This is needed for cookie based authentication to encrypt password in
 * cookie. Needs to be 32 chars long.
 */
$cfg['blowfish_secret'] = '8e41a8be54813c6b8f34b0fe6ebb5edb'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/**
...

Save and Exit the file

Restart Apache for the changes to take effect.

service apache24 restart

Access phpMyAdmin Web Interface

To access phpMyAdmin dashboard, navigate to the browser and enter the URL in the format, http://server-IP/phpmyadmin. This will take you to phpMyAdmin login page.

Install phpMyAdmin on FreeBSD

Login with MySQL database root credentials.

phpmyadmin dashboard

Running Database Queries on phpMyAdmin

You can see a list of databases on the left side of the phpMyAdmin Dashboard;

Select a database and you will see a list of all the tables it has. Take for example default mysql database.

phpmyadmin database tables

To run Queries against database tables, click SQL tab at the top and enter your queries on the SQL query interface.

For example;

SELECT User, Host, Plugin FROM user WHERE User = 'root';

Once you have the query, click on the “Go” button to execute the query.

run mysql queries on phpmyadmin

After execution, the results of your query will be displayed below the SQL query box.

query results phpmyadmin

You can continue executing more queries by writing them in the SQL query box and clicking “Go” each time.

Other Tutorials

You can also check our previous articles on LAMP/LEMP Stack using the following links;

How To Install LAMP (Linux, Apache, MySQL, PHP) Stack on Fedora 28/29

How to Install LAMP Stack (Apache,MariaDB, PHP 7.2) on Ubuntu 18.04 LTS

How to Install LEMP (Nginx,MariaDB,PHP7.2) Stack on Fedora 28 / Fedora 29

How To Setup LEMP Stack (Nginx, MariaDB, PHP 7.2) on Ubuntu 18.04