6.2. Building and Installing the Web Pages

Having obtained the documentation and web site source files, the web site can be built.

An actual installation of the web site is run as the root user because the permissions on the web server directory will not allow files to be installed by an unprivileged user. For testing, it can be useful to install the files as a normal user to a temporary directory.

In these examples, the web site files are built by user jru in their home directory, ~/doc, with a full path of /usr/home/jru/doc.


The web site build uses the INDEX from the Ports Collection and might fail if that file or /usr/ports is not present. The simplest approach is to install the Ports Collection.

Example 6.1. Build the Full Web Site and All Documents

Build the web site and all documents. The resulting files are left in the document tree:

% cd ~/doc/en_US.ISO8859-1/htdocs/
% make all

Example 6.2. Build Only the Web Site in English

Build the web site only, in English, as user jru, and install the resulting files into /tmp/www for testing:

% cd ~/doc/en_US.ISO8859-1/htdocs/
% env DESTDIR=/tmp/www make ENGLISH_ONLY=yes WEB_ONLY=yes all install

Changes to static files can usually be tested by viewing the modified files directly with a web browser. If the site has been built as shown above, a modified main page can be viewed with:

% firefox /tmp/www/data/index.html

Modifications to dynamic files can be tested with a web server running on the local system. After building the site as shown above, this /usr/local/etc/apache24/httpd.conf can be used with www/apache24:

# httpd.conf for testing the FreeBSD website
Define TestRoot "/tmp/www/data"

# directory for configuration files
ServerRoot "/usr/local"

Listen 80

# minimum required modules
LoadModule authz_core_module libexec/apache24/mod_authz_core.so
LoadModule mime_module libexec/apache24/mod_mime.so
LoadModule unixd_module libexec/apache24/mod_unixd.so
LoadModule cgi_module libexec/apache24/mod_cgi.so
LoadModule dir_module libexec/apache24/mod_dir.so

# run the webserver as user and group
User www
Group www

ServerAdmin you@example.com
ServerName fbsdtest

# deny access to all files
<Directory />
    AllowOverride none
    Require all denied

# allow access to the website directory
DocumentRoot "${TestRoot}"
<Directory "${TestRoot}">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted

# prevent access to .htaccess and .htpasswd files
<Files ".ht*">
    Require all denied

ErrorLog "/var/log/httpd-error.log"
LogLevel warn

# set up the CGI script directory
<Directory "${TestRoot}/cgi">
    AllowOverride None
    Options None
    Require all granted
    Options +ExecCGI
    AddHandler cgi-script .cgi

Include etc/apache24/Includes/*.conf

Start the web server with

# service apache24 onestart

The web site can be viewed at http://localhost. Be aware that many links refer to the real FreeBSD site by name, and those links will still go to the external site instead of the local test version. Fully testing the local site will require temporarily setting DNS so www.FreeBSD.org resolves to localhost or the local IP address.

Example 6.3. Build and Install the Web Site

Build the web site and all documents as user jru. Install the resulting files as root into the default directory, /root/public_html:

% cd ~/doc/en_US.ISO8859-1/htdocs
% make all
% su -
# cd /usr/home/jru/doc/en_US.ISO8859-1/htdocs
# make install

The install process does not delete any old or outdated files that existed previously in the same directory. If a new copy of the site is built and installed every day, this command will find and delete all files that have not been updated in three days:

# find /usr/local/www -ctime 3 -delete

All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.