How to Install phpMyAdmin with Nginx on FreeBSD
phpMyAdmin is a free and open-source web application tool for managing the MySQL or MariaDB database. The phpMyAdmin is primarily written in PHP and allows you to manage your MySQL/MariaDB databases from the web browser. You can easily create, update, import, and export your MySQL/MariaDB databases from one place dashboard.
This tutorial will show you how to install and configure phpMyAdmin on the FEMP Stack FreeBSD 12.0. We will install some additional PHP extensions, Install phpMyAdmin from the FreeBSD repository, and Configure it to work on the FEMP Stack environment.
Prerequisite
For this guide, we will use a server with FreeBSD 12.0 with 1GB of RAM and 2 CPUs. And make sure the FEMP Stack is installed on top of it. You can use the link below to install the FEMP Stack on your FreeBSD 12.0.
Install FEMP Stack on FreeBSD 12.0
What we will do:
- Install Additional PHP Extensions
- Install phpMyAdmin
- Configure phpMyAdmin
- Testing
Step 1 - Install PHP Extensions
Firstly, we need to install some of the PHP extensions needed for the phpMyAdmin installation.
Install some of the PHP extensions using the pkg command below.
pkg install php73-ctype php73-filter php73-mysqli php73-json php73-mbstring php73-session php73-hash php73-xml php73-openssl php73-bz2 php73-zip
Once all installations are complete, load all downloaded extensions by restarting the PHP-FPM service using the following command.
service php-fpm restart
Now check PHP extensions loaded.
php -m | egrep "ctype|filter|mysqli|json|mbstring|session|hash|xml|openssl|zip"
And you will get the result as below.
And as a result, all PHP extensions that needed for phpMyAdmin installation has been installed to the FreeBSD 12.0 system. And we're ready to install the phpMyAdmin package.
Step 2 - Install phpMyAdmin
By default, the FreeBSD provides the package for phpMyAdmin. So, we can install the phpMyAdmin package using the pkg package management tool.
To get the list of all available phpMyAdmin package on the FreeBSD repository, you can use the pkg search command as below.
pkg search phpmyadmin
Now you will get multiple version of phpMyAdmin.
Install the latest version of phpMyAdmin package using the command below.
pkg install phpMyAdmin-php73
Once the installation is complete, you will get the result as below.
The phpMyAdmin packages have been installed to the FreeBSD 12.0 system, and it's located at the '/usr/local/www/phpMyAdmin' directory.
Step 3 - Configure phpMyAdmin
After installing the phpMyAdmin, we will configure it to work with the Nginx web server on the FEMP Stack environment. The phpMyAdmin will be accessible from the server IP address with the URL path '/phpmyadmin'.
Before going any further, you will need to generate the phpMyAdmin blowfish secret using the online tool generated below.
https://phpsolved.com/phpmyadmin-blowfish-secret-generator/
Open the link with your browser and copy the blowfish secret generated to your note.
Next, we will create a new symlink for the phpMyAdmin directory to the default Nginx document root directory.
Create a new symlink for the '/usr/local/www/phpMyAdmin/' directory to the Nginx document root directory '/usr/local/www/nginx/phpmyadmin' using the following command.
ln -s /usr/local/www/phpMyAdmin/ /usr/local/www/nginx/phpmyadmin
After that, go to the '/usr/local/www/phpMyAdmin/' directory and copy the example configuration to 'config.inc.php'.
cd /usr/local/www/phpMyAdmin/
cp config.sample.inc.php config.inc.php
Then edit the 'config.inc.php' file using the vim editor.
vim config.inc.php
Paste the blowfish secret that you have generated on top.
$cfg['blowfish_secret'] = 'dsz79ufuF38T06Il0}BieN:pc=4vAJRB';
Save and close.
Now that the phpMyAdmin configuration has been completed, restart the Nginx service using the following command.
service nginx restart
As a result, the phpMyAdmin will be accessible from your web browser on the path '/phpmyadmin'.
Step 4 - Testing
Open your web browser, type the server IP address, and follow the 'phpmyadmin' path on the address bar.
http://10.5.5.25/phpmyadmin/
Now you will get the phpMyAdmin login page as below. Log in with your MySQL/MariaDB username and password.
Once you log in, you will get the phpMyAdmin dashboard below.
As a result, the phpMyAdmin installation and configuration with Nginx web server inside the FEMP Stack environment and using the FreeBSD 12.0 has been completed successfully.