Learn how to Install Apache2, MariaDB and PHP (FAMP) Stack on FreeBSD
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
pkg updateInstall Apache2 by executing the following command:
pkg install apache24Start the Apache2 service by running:
sysrc apache24_enable=YES service apache24 startVerify 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
pkg install mariadb105-serverEnable MariaDB to start on system boot and start the service:
sysrc mysql_enable=YES service mysql-server startSecure your MariaDB installation by executing:
mysql_secure_installationFollow 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
pkg install php74 mod_php74Configure PHP to work with Apache2 by editing the /usr/local/etc/apache24/httpd.conf file:
vi /usr/local/etc/apache24/httpd.confUncomment the line LoadModule php7_module libexec/apache24/libphp7.so by removing the leading. Save the file and exit. Restart Apache2 to enable the PHP module:
service apache24 restartCreate 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.