FreeBSD phpMyAdmin Starter With Apache24

This article presents a simple way on how to install phpMyAdmin on FreeBSD 13.2 Stable, phpMyAdmin is a free and open source application written in PHP language to manage MySQL and MariaDB tasks such as creating, changing, deleting, deleting database tables, or executing other database management commands and support for most MySQL features.

phpMyAdmin supports multiple database servers. This application can also import data from various formats such as CSV and SQL, and also export data to various other formats such as CSV, SQL, XML, PDF, ISO/IEC 26300 - OpenDocument Text and Spreadsheets, Word, Excel, LATEX and others . It's free, open source, and written using PHP.

This article will not explain how to install Apache Web Server, about how to install Apache you can read the previous article on this blogspot. In this article we assume that our FreeBSD system has apache24 installed.
To start installing phpMyAdmin in this tutorial the tips will be to use the FreeBSD system ports. Installing phpMyAdmin with system ports shouldn't be too difficult. You just follow the steps in this article.


1. System Requirements

OS: FreeBSD13.2 Stable
IP LAN Server: 192.168.9.3
Apache: apache24 (In this article we will not discuss it, we will assume it is already installed)
MySQL:  mysql80-server (In this article we will not discuss it, we will assume it is already installed)
php: php82
phpMyAdmin: phpMyAdmin5-php82


2. phpMyAdmin installation

Before we go into the installation process, once again I remind you that this tutorial does not discuss installing apache24 and mysql80-server, you can read the previous article which discusses these two applications. Now let's start installing phpMyAdmin, but before that you first install php82.

root@router2:~ # cd /usr/ports/lang/php82
root@router2:/usr/ports/lang/php82 #
make install clean
After completing installing php82, then we continue by installing phpMyAdmin.

root@router2:~ # cd /usr/ports/databases/phpmyadmin5
root@router2:/usr/ports/databases/phpmyadmin5 #
make install clean
The display below is what it looks like when the phpMyAdmin installation is complete.

Installing phpMyAdmin5-php82-5.2.1_1...
===> Creating groups.
Using existing group 'www'.
phpMyAdmin5-php82-5.2.1_1 has been installed into:

/usr/local/www/phpMyAdmin

Please edit config.inc.php to suit your needs.

To make phpMyAdmin available through your web site, I suggest
that you add something like the following to httpd.conf:

Alias /phpmyadmin/ "/usr/local/www/phpMyAdmin/"

<Directory "/usr/local/www/phpMyAdmin/">
Options None
AllowOverride Limit

Require local
Require host .example.com
</Directory>


SECURITY NOTE: phpMyAdmin is an administrative tool that has had several
remote vulnerabilities discovered in the past, some allowing remote
attackers to execute arbitrary code with the web server's user credential.
All known problems have been fixed, but the FreeBSD Security Team strongly
advises that any instance be protected with an additional protection layer,
e.g. a different access control mechanism implemented by the web server
as shown in the example. Do consider enabling phpMyAdmin only when it
is in use.
===> Cleaning for php82-ctype-8.2.6
===> Cleaning for php82-ctype-8.2.6
===> Cleaning for php82-filter-8.2.6
===> Cleaning for php82-filter-8.2.6
===> Cleaning for php82-iconv-8.2.6
===> Cleaning for php82-iconv-8.2.6
===> Cleaning for php82-mysqli-8.2.6
===> Cleaning for php82-mysqli-8.2.6
===> Cleaning for php82-session-8.2.6
===> Cleaning for php82-session-8.2.6
===> Cleaning for php82-xml-8.2.6
===> Cleaning for php82-xml-8.2.6
===> Cleaning for php82-xmlwriter-8.2.6
===> Cleaning for php82-xmlwriter-8.2.6
===> Cleaning for php82-bz2-8.2.6
===> Cleaning for php82-bz2-8.2.6
===> Cleaning for php82-gd-8.2.6
===> Cleaning for php82-gd-8.2.6
===> Cleaning for php82-mbstring-8.2.6
===> Cleaning for php82-mbstring-8.2.6
===> Cleaning for oniguruma-6.9.8_1
===> Cleaning for oniguruma-6.9.8_1
===> Cleaning for php82-zip-8.2.6
===> Cleaning for php82-zip-8.2.6
===> Cleaning for libzip-1.9.2
===> Cleaning for libzip-1.9.2
===> Cleaning for php82-zlib-8.2.6
===> Cleaning for php82-zlib-8.2.6
===> Cleaning for phpMyAdmin5-php82-5.2.1_1
===> Cleaning for phpMyAdmin5-php80-5.2.1_1
===> Cleaning for php81-8.1.19
===> Cleaning for php81-8.1.19
===> Cleaning for php81-ctype-8.1.19
===> Cleaning for php81-ctype-8.1.19
===> Cleaning for php81-filter-8.1.19
===> Cleaning for php81-filter-8.1.19
===> Cleaning for php81-iconv-8.1.19
===> Cleaning for php81-iconv-8.1.19
===> Cleaning for php81-mysqli-8.1.19
===> Cleaning for php81-mysqli-8.1.19
===> Cleaning for php81-session-8.1.19
===> Cleaning for php81-session-8.1.19
===> Cleaning for php81-xml-8.1.19
===> Cleaning for php81-xml-8.1.19
===> Cleaning for php81-bz2-8.1.19
===> Cleaning for php81-bz2-8.1.19
===> Cleaning for php81-gd-8.1.19
===> Cleaning for php81-gd-8.1.19
===> Cleaning for php81-mbstring-8.1.19
===> Cleaning for php81-mbstring-8.1.19
===> Cleaning for oniguruma-6.9.8_1
===> Cleaning for oniguruma-6.9.8_1
===> Cleaning for php81-zip-8.1.19
===> Cleaning for php81-zip-8.1.19
===> Cleaning for libzip-1.9.2
===> Cleaning for libzip-1.9.2
===> Cleaning for php81-zlib-8.1.19
===> Cleaning for php81-zlib-8.1.19
===> Cleaning for phpMyAdmin5-php81-5.2.1_1
root@router2:/usr/ports/databases/phpmyadmin5 #

The picture above will appear after the phpMyAdmin installation process is complete, what you have to pay attention to is the red writing. OK, let's continue the configuration process, after you have finished installing phpMyAdmin, the next step is to copy the config.sample.inc.php file to the config.inc.php file. The file is located in the /usr/local/www/phpMyAdmin folder.

root@router2:~ # cd /usr/local/www/phpMyAdmin
root@router2:/usr/local/www/phpMyAdmin #
cp config.sample.inc.php config.inc.php
3. Edit File httpd.conf

In this third step we will edit the /usr/local/etc/apache24/httpd.conf file. Editing this file will provide the url to access phpMyAdmin. Enter the red script above into the httpd.conf file. Place the script below at the very bottom or at the very end of the httpd.conf script.

Alias /phpmyadmin "/usr/local/www/phpMyAdmin/"
<Directory "/usr/local/www/phpMyAdmin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

4. Apache24 mod php installation

Now we continue by installing the php mod so that it can run on the apache24 web server.

root@router2:~ # cd /usr/ports/www/mod_php82
root@router2:/usr/ports/www/mod_php82 #
make install clean

root@router2:~ #
cd /usr/ports/databases/php82-mysqli
root@router2:/usr/ports/databases/php82-mysqli #
make install clean
After the two applications above have been installed, we continue by editing the httpd.conf file, in the script below.

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
Add the index.php script, so the script looks like the following.

<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
Still in the httpd.conf file, place the following script at the end or bottom of the httpd.conf file script.

LoadModule php_module         libexec/apache24/libphp.so

<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>

Next, we create the php.ini file, by copying the php.ini-production file to php.ini. The file is located in the /usr/local/etc folder.

root@router2:~ # cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
After that, in the /usr/local/etc/php.ini file, we add the following script.

extension=mysqli.so
Create a new file with the name info.php and place it in the /usr/local/www/apache24/data folder. In the info.php file, enter script "<?php phpinfo(); ?>"

root@router2:~ # touch /usr/local/www/apache24/data/info.php
root@router2:~ #
ee /usr/local/www/apache24/data/info.php
<?php phpinfo(); ?>

After that, do a test by typing the url: http://192.168.9.3/info.php, in the Google Chrome or Yandex address bar menu.

We also tested phpMyAdmin by typing the url: http://192.168.9.3/phpmyadmin/ in Yandex browser or Google Chrome.

Use the username and password from MySQL Server to log in






Well, if it appears like the image above, it means we have successfully installed phpMyAdmin on the FreeBSD system. To fill in the password, use the name and password from the MySQL server that we installed previously.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post