Learn how to Install Apache2, MariaDB and PHP (FAMP) Stack on FreeBSD


In this article, we will explore the process of installing the FAMP stack on a FreeBSD server. FAMP stands for FreeBSD, Apache2, MariaDB, and PHP, and it is a popular web development environment. By following this guide, you will be able to set up a robust and efficient server that is capable of running dynamic websites and applications. So, let’s dive right in and learn how to install Apache2, MariaDB, and PHP on your FreeBSD system!


Before we start with the installation process, there are a few prerequisites for setting up the FAMP stack on your FreeBSD server. Make sure you have:

1) A FreeBSD server with root access.
2) An internet connection to download the necessary packages.
3) Basic knowledge of the command line and shell.

Now that we have everything in place, let’s proceed with the installation.

Installing and Configuring Apache2

Apache2 is a widely used web server that provides a stable and robust platform for hosting websites. To install Apache2 on FreeBSD, follow these steps: Update your package repository by running the following command:
pkg update
Install Apache2 by executing the following command:
pkg install apache24
Start the Apache2 service by running:
sysrc apache24_enable=YES
service apache24 start
Verify if Apache2 is running by opening a web browser and navigating to http://your_server_ip. You should see the Apache2 default page. Apache2 is installed and running on your FreeBSD server! You can further customize its configuration by editing the /usr/local/etc/apache24/httpd.conf file.

Installing and Configuring MariaDB

MariaDB is a powerful and feature-rich relational database management system that can be used as a drop-in replacement for MySQL. To install and configure MariaDB on your FreeBSD server, follow these steps: Install MariaDB by running the following command:
pkg install mariadb105-server
Enable MariaDB to start on system boot and start the service:
sysrc mysql_enable=YES
service mysql-server start
Secure your MariaDB installation by executing:
Follow the on-screen instructions to set a password for the root user, remove anonymous users, disable remote root login, and remove the test database. This step will enhance the security of your database. MariaDB is now installed, configured, and ready to use on your FreeBSD server!

Installing and Configuring PHP

PHP is a popular scripting language used for web development. To install and configure PHP on your FreeBSD server, follow these steps: Install PHP by running the following command:
pkg install php74 mod_php74
Configure PHP to work with Apache2 by editing the /usr/local/etc/apache24/httpd.conf file:
vi /usr/local/etc/apache24/httpd.conf
Uncomment the line LoadModule php7_module libexec/apache24/ by removing the leading. Save the file and exit. Restart Apache2 to enable the PHP module:
service apache24 restart
Create a test PHP file to verify the installation. Open a text editor and create a file called info.php in the /usr/local/www/apache24/data/ directory. Insert the following content: Save the file and navigate to http://your_server_ip/info.php in your web browser. If PHP is installed correctly, you should see detailed information about your PHP configuration.


Congratulations! You have successfully installed the FAMP stack (FreeBSD, Apache2, MariaDB, and PHP) on your FreeBSD server. You now have a powerful web development environment capable of running dynamic websites and applications. Feel free to explore the possibilities of this stack and start developing your web projects with ease. Happy coding!
Scroll to Top