How to Install Apache, MariaDB, and PHP (FAMP) stack on FreeBSD 11

freebsd

In this tutorial we will show you how to install Apache, MariaDB, and PHP on FreeBSD 11. If you dont know FAMP is the acronym of FreeBSD, Apache, MySQL/MariaDB, PHP. FreeBSD 11 is the latest version right now when this article was made.

Prerequisites
Before you begin with this guide, you should at least have basic knowledge of linux or unix, know basic shell command for linux or unix, have login as root user and of course you need FreeBSD 11 installed on your PC or server.

Step 1 – Update your FreeBSD

Before we continue to installing any software , we need to update first our FreeBSD 11 operating system.

Run the following commandson your FreeBSD server.

If you have been installed lates update you should get output like these

Step 2 – Install Apache Webserver

We will install apache 2.4 using pkg command.

If you first time using pkg command in your operating system you should get notification yo install package management tool , just choose y

Next , we enable apache to run at boot time using these command

Start the apache service using these command

Test apache web service

Before we test apache , we need to configure apache configuration

Edit this file using nano  /usr/local/etc/apache24/httpd.conf

Find and edit this variable like these based on your ip address or hostname , in this example we using ip address 192.168.14.126

Exit and save the file

Then restart apache service using these command

Now, open your web browser and navigate to: http://IP-address/ or http://localhost/. You’ll see the following Apache test page.

freebsd11 apache

Step 3 – Install MariaDB

MariaDB is drop-in replacement of MySQL.It has same process name , same syntax and configuration. To install run these following pkg command

Copy MariaDB example configuration from directory ‘/usr/local/share/mysql/’ to ‘/usr/local/etc/

Enable and start MariaDB service

In default MariaDB installation  root password was empty. For security reason we will create root password using this command

When prompt “Enter current password for root”, just press ENTER key and set the password twice. Then simply press Y to accept the default values.

Sample output

Step 4 – Install PHP

We need php to server dinamic content, to install PHP run these following command

After installation success , we need to copy php.ini sample configuration

Update changes with this command

We need configure PHP with apache webserver , so we need edit apache configuration file using nano

Find the DirectoryIndex section and add index.php in front of the existing index.html as shown below.

And then, add the following lines at the bottom of Apache configuration file

Save and close the file

We need restart Apache web server to take change configuration

Step 5 – Test PHP

To test PHP we will create sample php script using nano

Add the following line

Save and close the file

Open web browser and navigate to your server address http://IP-Address/test.php , here example output

screenshot_2016-09-30_14-02-47

Step 6 – Install PHP Modules (Extensions)

In order to get full functioning your PHP script sometimes we need to install some additional PHP modules (extensions), you can skip this step if you don’t need to install any extensions.
To view the list of available modules, just run

Sample output :

You can verify what each module does from the comment section in the above output, or just run the following command

Sample output:

To install php extension , for example we will install php56-curl , run with this following command

To take change after installation , apache web service need to be restarted

Congratulations , you have successfully install Apache, MariaDB, and PHP (FAMP) stack on FreeBSD 11, now you’re ready to host your websites or any web based applications.

2 Responses

  1. RosalineQps says:

    I see your blog needs some unique & fresh articles. Writing manually is time consuming,
    but there is tool for this task. Just search for; Digitalpoilo’s tools

  2. Elmo89 says:

    Reading your blog is big pleasure for me, it deserves
    to go viral, you need some initial traffic only.
    If you want to know how to get it search for: blackhatworren’s strategies

Leave a Reply

Your email address will not be published. Required fields are marked *