headerImage

Contents

Introduction

By default, the base FreeBSD system that we've been stepping through installing has no ability to serve up web pages. Wait a minute! Why do we need to serve up web pages from our server? Why can't we just use the tried and true command line interface?

Your shiny new FreeBSD Embedded Development server is going to be used by the rest of the development group, and maybe even by managers. They are not going to use a command line, and you need to be sure that the entire team buys into the idea of centralized bug or issue tracking and source code management.

That means using an interface they are familiar with, which is either a rich client on their desktop, or a browser.

We're installing Apache 2 so that the rest of the team can actually use the system to get a better handle on the company's products.

In this article, we'll get Apache 2 installed from source, just like we have already done for perl and postfix. Then we'll go through setting up a place on the web where we can access the server from anywhere else on the Internet.

Resources

The Apache 2 program has a wide following, so natuarally it has its own web site.

Another article you may find useful is Securing Apache 2: Step-by-Step. This one is jam-packed with good information on setting up Apache 2 in a chrooted environment, and you can use the techniques for other applicaitons as well.

Installing Apache 2 from cvs

Installing Apache 2 from source is relatively straightforward. As always, the first thing to do is figure out if the port requires any other libraries or applications. This is relatively easy if you use the FreeBSD Posts Search page to look for ports with "apache2" in the package name. The previous article on postfix goes into quite a bit of detail on this.

To cut a long story short, here are the Apache 2 dependencies, with duplicate dependencies removed:

  www/apache2
  +- devel/autoconf
  |  +- devel/gettext
  |  +- devel/gmake
  |  +- misc/help2man
  |     +- devel/p5-Locale-gettext
  +- textproc/expat2
  |  +- devel/libtool13
  +- converters/libiconv
  +- devel/libtool15      * already installed
  +- devel/m4
  +- security/openssl     * already installed
  +- lang/perl5.8         * already installed
  +- sysutils/rc_subr

Remember that you figure out the download name of the port by clicking on the "Description" link and checking the title of the page you end up on. After a while, you'll figure out that you can just hover the mouse over the "Description" link and get the name from the status bar of your browser.

Now we have enough information to go and get the relevant port files to build postfix. Here are the commands I used to get the Apache2 requirements, as root of course.

setenv CVSROOT :pserver:anoncvs@anoncvs.fr.FreeBSD.org:/home/ncvs
cd /usr
cvs login
cvs checkout -A -P -r RELEASE_4_10_0 ports/www/apache2
cvs checkout -A -P -r RELEASE_4_10_0 ports/devel/autoconf
cvs checkout -A -P -r RELEASE_4_10_0 ports/devel/gettext
cvs checkout -A -P -r RELEASE_4_10_0 ports/devel/gmake
cvs checkout -A -P -r RELEASE_4_10_0 ports/misc/help2man
cvs checkout -A -P -r RELEASE_4_10_0 ports/devel/p5-Locale-gettext
cvs checkout -A -P -r RELEASE_4_10_0 ports/textproc/expat2
cvs checkout -A -P -r RELEASE_4_10_0 ports/devel/libtool13
cvs checkout -A -P -r RELEASE_4_10_0 ports/converters/libiconv
cvs checkout -A -P -r RELEASE_4_10_0 ports/devel/m4
cvs checkout -A -P -r RELEASE_4_10_0 ports/sysutils/rc_subr
cvs logout

Building Apache 2 should now simply be a matter of:

cd /usr/ports/www/apache2
make install

...but the build craps out when it can't find autoconf, so we'll need to build autoconf by hand first...

cd /usr/ports/devel/autoconf
make install

It's an interactive build script, and when it tries to build gettext there's an options screen that lets you install examples and help files in HTML format. Select them if you like, then tab over to OK and hit Enter to continue the build.

Get a drink, stretch, pet the dog, or clean up the office. This part takes a few minutes...and then you'll get a message about gmake not being installed either! So go and build gmake.

cd /usr/ports/devel/gmake
make install

And we can get back on track and finish the autoconf build...

cd /usr/ports/devel/autoconf
make install

And maybe now we can finish what we started, which if you're still paying attention is Apache 2...

cd /usr/ports/www/apache2
make install

Get another drink, maybe even beer if it's a hot day. Or maybe you should stick to cleaning up the office. Eventually the build completes, so now we can move along and do the post-install testing and configuration.

Starting and Testing Apache 2

Apache is set to start when the system is rebooted, but hold on, this isn't a Windows machine! You can start Apache from the command line like this:

funkenfanger# apachectl start
httpd: Could not determine the server's fully qualified domain name, using 192.168.1.2 for ServerName
funkenfanger#

The warning is just that the ServerName can't be determined because we haven't specified a fully qualified domain name, like www.example.com or whatever your real domain name is. No worries, let's see if we can get to the server from a browser on another machine. In the address bar, of a browser on a machine that's on the same network as your new server, enter something like:

http://192.168.1.2:80

Use whatever the actual IP adress of your server is, and make sure you remember to tack on the :80 at the end. This is the port number that Apache 2 listens to for requests from the Internet.

If everything works as expected, you'll see something like this:

Apache 2 Test Page

Making Your Server Visible on the Net

OK, so we've got the server running Apache 2, we can see the test page from a browser on a machine on our internal network, and we're feeling pretty good about wrestling with building Apache 2 from source.

Now we need to take the next step and make the Apache server visible to the rest of the Internet.

But wait, you say. I'm on a DSL connection and my stupid ISP keeps reassigning the IP adress of my modem everytime I reconnect to the Internet. This is where the magic of Dynamic DNS (or similar services) come in.

In a nutshell, Dynamic DNS is a way to take an easily remembered name and map it to a changing IP address. Normally, the Internet works by having a fixed address for each domain name. If you have a dialup or DSL connection provided by your local ISP, then that adress will change every time you dial in or reconnect.

You could just change your DNS records every time that happened if you were willing to put up with up to 48 hours of your site being unreachable. Not the best option.

What Dynamic DNS does is provide a fixed adress on their site for a domain name of your choosing, and then their site redirects to the IP adress that you specify. Oh, and they do it for free, if you're willing to use one of their domain names. Once you have tried the service, it's pretty clear that it works so you should have no second thoughts about upgrading to the not-free service.

I won't go into too many details of how to set this up, but if you check out the actual Dynamic DNS Service, there is lot's of information there, including a list of top-level domains and automatic update clients.

For the initial test setup, you'll need to provide them with the actual IP address that your ISP has given you. As an example, I've included the following screenshot from my Linksys router...

Router DNS Setting

I've set up my free Dynamic DNS domain as but you can pick any other name that works with their redirect service. Enter that URL into your browser and you should see the exact same Apache 2 test page.

Congratulations, you've completed the basic install of a useful server. Next, we'll customize it for Embedded Systems Development by addig a bug tracker and conde management system.