Home / Articles / BSD / FreeBSD / Install Apache in FreeBSD

Install Apache in FreeBSD

Install Apache in FreeBSD
Install Apache in FreeBSD
Authors: Sergey Fedus
  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 5/5 (2 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.

Installing and configuring the Apache 2.2.x web server in FreeBSD.


To begin the Apache installation process, log in like the superuser and enter the following commands:

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

A menu should appear to show options for Apache. Here you may leave default options, but If you need to build and install Apache with special modules then you have to choose them now. For example if you want your Apache to support the working with MySQL databases then you need to select it in the menu by pressing 'space'. After choosing needed options you can start to install Apache by pressing 'tab' and 'enter'.


We are going to configure Apache to start automatically at boot time. To do so, edit the /etc/rc.conf file and add the following line to the end of file:


After this we will make base configuration which is enough to run Apache. Open the file /usr/local/etc/apache22/httpd.conf. In this file you need to find and set values for two options:

ServerAdmin admin@example.com
ServerName host.example.com:80

Where options:

  • ServerAdmin is email address of the person who will be maintaining the server.
  • ServerName is hostname of your server

If you don't have hostname which pointed to server's IP then you may set any hostname, but then you will need to set this hostname and IP in your local PC which you use for browsing current server.
You need to add following line to file:

  • for Windows C:\WINDOWS\system32\drivers\etc\hosts
  • for Linux /etc/hosts host.example.com

Where is IP for your server where you are installing Apache.

After you completed configuring Apache you can check your config file for syntax errors by running this command:

/usr/local/etc/rc.d/apache22 configtest

If it returns "Syntax OK", continue below. If it finds a problem, it will list the filename, line number, and possible reasons for the error. Be sure to resolve any issues prior to continuing below.

After these you can run Apache by command:

/usr/local/etc/rc.d/apache22 start

Now you can open any browser and check how it works. For this example "host.example.com".

Log files

  • /var/log/httpd-access.log contains a log of IP addresses, times, and activity on the HTTP server
  • /var/log/httpd-error.log contains a log of error messages produced by the HTTP server

Read also

Install MySQL server on FreeBSD

Install MySQL server on FreeBSD

Log in or create a user account to post a comment.


Quick navigation

General navigation