header pictures for dedicated hosting services

How to Install Apache22 for FreeBSD - installation guide

The FreeBSD Ports Collection is a very easy way for users and administrators to compile and install their applications like Apache on a FreeBSD machine. You can type "make install clean" in corresponding directory, the system will automatically fetches the application source code, either from a local disk or via FTP, unpacks it on your system, applies the patches, and compiles it. If all goes well, simply type “make install” to install the application.

Before using the ports system, you need to make sure you have the ports collection installed. You can run the following command to check:

Note: throughout this document, “FreeBSD#” is the hostname and the prompt, while the rest is the command we have to input.

FreeBSD# ls /usr/ports

If this command brings up a list of directories, the ports collection is installed and ready to go. If there is an empty directory listing or it reports an error like "No such file or directory", then you need to download the ports collection and unpack it on your system. Instructions for installing the ports collection is here.

ONe installed you are ready to install the Apache web server

Installing Apache on a FreeBSD Server

We can start with our apache22 installation

FreeBSD# cd /usr/ports/www/apache22
FreeBSD# make install clean

This will install apache2 under /usr/local. If you want to install apache2 somewhere else, use the following command instead:

FreeBSD# make prefix=/mywebsite/apache2 install clean

Then you have the choices to select which apache2 modules you want to install, as shown below. Default options should work for most situations, unless you intend to install any specific module, you can accept default options.

If you need to install any module, just use arrow key to go to the module you need and then press space key to select it, then use Tab key to highlight [ OK ] and press Enter to finish your configurations. The ports system will take care of the rest. Depends on your Internet connection bandwidth and files need download, this will take 10 to 30 minutes.

Screen showing the options menu for apache 2.2.6_2 with "enable mod_mime" selected

If you don't see any errors or complaints, then your apache22 is installed. You can find it at /usr/local/www/apache22, web documents should be placed under /usr/local/www/apache22, and the apache2 configuration file is located under /usr/local/etc/apache22/, binaries goes to /usr/local/sbin/

Now you can start apache2 and see how it goes:

FreeBSD# /usr/local/sbin/apachectl start

You may get errors like the following:
[Fri Mar 27 05:40:04 2009] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter

Still you can test your apache22 by pointing your browser to http://your-host-name, you should be able to see a page that just says "It works!". It's just a message to tell you apache22 is working.

To resolve above errors, run the following commands:

FreeBSD# kldload accf_data
FreeBSD# kldload accf_http

To tell FreeBSD load these 2 modules at boot time, edit /boot/defaults/loader.conf with your favorite editor, like ee,


FreeBSD# ee /boot/defaults/loader.conf

Then you’ll see a screen similar to below picture:

picture showing the loader.conf in the ee editor

and then find the below two lines. You can use Ctrl+v key to go to next page

accf_data_load="NO" # Wait for data accept filter
accf_http_load="NO" # Wait for full HTTP request accept filter

Replace "NO" with "YES" and then save the change by pressing “ESC”, then "a", then "b". Now you're good to go. Fine tune your httpd.conf file if needed.

Explanation of the Ports Collection

Basically, ports is the way we install software packages on a FreeBSD system, as long as it's included in the ports system. To search ports collection and see if a software is included, run the following command:

FreeBSD# cd /usr/ports
FreeBSD# make search key="your_application_name"

Search the output and see if your applicaiton is included or if there is anything related. If nothing comes out from the search, that means we don't have it in ports collection.



Looking for our FreeBSD Forums? We have moved them off our main page,just follow the link to our FreeBSD Forums page.

Guests Visit the FreeBSD Forums  •  Login to the FreeBSD Forums  •  Register for FREE
Custom Search


Privacy Policy

Please note:
(1) FreeBSD is a registered trademark of The FreeBSD Foundation.
(2) WEBSERVER CONSUMER GUIDE is in no way affiliated with The FreeBSD Foundation