Install Apache MariaDB and PHP 7 on FreeBSD 11


I know this wonderful system for a very long time. I like it and it’s giving me the feeling of security and transparency, the system was hacked some years ago but now, it looks strong and more open. One of the most powerful things on FreeBSD is the stability and the Solid File system.  let me tell you how I have installed FAMP  (FreeBSD Apache MariaDB PHP)  on my VirtualBox.

My Test Server is FreeBSD based on VirtualBox tool and its running fine

Install Apache 2.4 in FreeBSD

To install Apache, please use the tool pkg to avoid any dependencies issues:

Start Apache at boot

To run apache www server from startup, add

Start Apache

Apache conf file in FreeBSD is  “/usr/local/etc/apache24/httpd.conf”

Apache DocumentRoot in FreeBSD is under  “/usr/local/www/apache24/data”

Check if  Apache web server is running

Go to http://IP

It works!!

How to install  MariaDB On FreeBSD 11.x

Show the available release:

Now, install the latest Server and Client release 

Now set mysql_enable to YES in /etc/rc.conf  to automate starting MySQL server on next reboot

I’m setting up a medium sized server, so I’m going to copy /usr/local/share/mysql/my-medium.cnf to /usr/local/etc/ directory using cp command: # cp /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf

Set MySQL root password

Alternatively, you can run:

If facing any problem, don’t hesitate to remove all files inside /var/db/mysql :

root@osradarFreeBSD:~ # rm -rf /var/db/mysql/*

Restart MySQL and check

Install   PHP 7 on FreeBSD 11

You need 2 packages  mod_php71 php71-mysqli

Copy your php.ini from the template:

In order to configure PHP, you needed to edit the httpd.conf file.

Make sure that the line to load the php7_module did exist, and add the  AddType below:

 In the dir_module entry, added index.php to the existing index.html in the DirectoryIndex:

Also, add the following lines at the end of the file:


Check if the syntaxes are ok.

Now, create the PHP info test  page


<?php phpinfo(); ?>

Restart  apache and  check http://ip/test.php

Install phpMyAdmin on FreeBSD 11

phpMyAdmin is also available in default repository of FreeBSD. You can install phpMyAdmin directly by running the following command.

Please find the release of phpMyAdmin:

Install now the release compatible with your PHP:

The above command will download and install phpMyAdmin. The application will be installed in /usr/local/www/phpMyAdmin/ directory.

Copy the sample phpMyAdmin configuration  from the templates:

Make an symbolik of phpmyadmin in Root apache  folder .

Restart the Apache web server by running:

Access phpMyAdmin

you can access from http://ip/phpmyadmin


Spread the love
  • 13

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.


  1. Thank you for this very usefull tuto!
    I just applied it with FreeBSD 11.2 installed on an old ASUS-Pundit 32 bits.
    It works fine but only if I remove the new lines :

    SetHandler application/x-httpd-php

    SetHandler application/x-httpd-php-source

    If I keep it, Apache server does’nt interpret PHP code.


Please enter your comment!
Please enter your name here