At RootBSD people ask us why we prefer *BSD over Linux. The truth is that these days, you can use almost anything to get things done - and Linux, OS X (based on the Mach kernel of course), and even Windows ( sigh ) are tools used in the wild, along with *BSD's.

So why do we use FreeBSD? Why use a butter knife when you can use a steak knife - or a multi tool? Over decades (yes, we're getting old) we've found that *BSD gets us where we need to be with the lowest TCO (total cost of ownership) and highest ROI (return on investment).

In this series we’ll walk through the differences (and similarities) between running various server configurations on FreeBSD vs Linux. Once tied together, the advantages of using FreeBSD will be apparent although we suspect you’ll have realized them already!

The differences between running a web server on FreeBSD versus a Linux distro are minimal for the most part and may only be noticed by a user switching from one they're familiar with to one they're not as familiar with. Both are derived from Unix but FreeBSD is closer to the Unix ancestors than modern Linux distros. An administrator comfortable with old-school Unix systems may prefer and feel more comfortable with FreeBSD, for example, but learning to navigate the file structure and package installation of one coming from the other requires only a small learning curve.

Furthermore, spinning up a FAMP stack using FreeBSD is no more difficult or different than spinning up a LAMP stack on Linux. Installing a basic FAMP stack doesn't even require navigating the ports tree.

RootBSD Cloud Servers Banner

Package Installation

For installing specialized packages, FreeBSD uses the ports tree but most packages you would need for a FAMP stack are available as binaries from a repository maintained by FreeBSD. This is pretty much the same as installing a LAMP stack on Linux; most packages needed are available as binaries from repositories maintained by the Linux distro you're using. The only difference is the command used to install them.

Installing packages for a basic web server on FreeBSD is just as easy as it is with Linux.

Example: Install Apache 2.4

FreeBSD:

pkg install apache24

Debian Linux:

apt-get install apache2

FreeBSD requires additions to /etc/rc.conf in order to start certain services on reboot while some Linux distros require no additional input or just a single command. We'll go over installation specifics in a later article.

Firewall

Any administrator running a LAMP or FAMP stack web server will also want a firewall. The firewall options for FreeBSD vs Linux are probably what separates the two the most. Linux uses iptables while FreeBSD uses ipfw; both can be used as line-by-line commands or written into a shell script but the syntax between them is significantly different. However, if you're very familiar with one learning the other (or at least doing what you need for basic FAMP or LAMP stack firewall security) is really only a matter of syntax difference, keeping in mind FreeBSD's ipfw rules require unique rule numbers. Some people may find FreeBSD’s ipfw easier to use than Linux’s iptables due to ipfw’s use of more natural language.

Example: Allow http and https traffic into web server (ports 80 and 443)

FreeBSD ipfw:

ipfw -q add [rule number] allow tcp from any to any 80 in
ipfw -q add [rule number] allow tcp from any to any 443 in

Linux iptables:

iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 443 -j ACCEPT

That concludes the first part of our FreeBSD vs Linux series. Keep an eye out for the next installment!

FreeBSD vs Linux

FAMP Stack FAQs

1
Is FreeBSD difficult to use as a web server?

FreeBSD is no more difficult to use as a web server than Linux. It only requires becoming familiar with a very slightly different file structure, learning how to install packages directly from the ports tree for more advanced usage, and learning some replacement commands (i.e. "free -m" is not available on FreeBSD).

2
I need to run a special application on my web server like Node.js or anything else beyond the basic FAMP stack. Can I do this with FreeBSD?

Absolutely, if the application has been ported to FreeBSD. You'll want to check the ports tree for the application you need to run. At the time of this post, Node.js is available for FreeBSD.

3
My web application needs to run on Nginx instead of Apache. Is that possible with FreeBSD?

Yes, the Nginx http server is available in the FreeBSD ports tree and pkg.

Questions about running FreeBSD as a web server? Drop it here and we'll answer you personally! The most common questions will be included in future articles.

Ready to deploy a FreeBSD server instantly?

Take a look at our plans and get started building your FreeBSD FAMP stack in seconds to any of our 25+ global locations!