Apache-2.4.1

Introduction to Apache

The Apache package contains an open-source HTTP server. It is useful for creating local intranet web sites or running huge web serving operations.

This package is known to build and work properly using an LFS-7.1 platform.

Package Information

Apache Dependencies

Required

Apr-Util-1.4.1

Optional

OpenLDAP-2.4.31, Berkeley DB-5.3.15, expat-2.1.0, OpenSSL-1.0.1a, PCRE-8.30, rsync-3.0.9, Doxygen-1.7.5, Lynx-2.8.8dev.10 and distcache

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/apache

Installation of Apache

For security reasons, running the server as an unprivileged user and group is strongly encouraged. Create the following group and user using the following commands as root:

groupadd -g 25 apache &&
useradd -c "Apache Server" -d /dev/null -g apache \
        -s /bin/false -u 25 apache
[Note]

Note

The above command directs the Apache user's home directory to /dev/null. This may not work for some add-ons such as ViewVC, a browser interface for CVS and Subversion version control repositories. See the User Notes for details for specific applications.

Build and install Apache by running the following commands:

cat >> config.layout << "HERE_DOC" &&
# BLFS FHS layout
<Layout FHS>
    prefix:          /usr
    exec_prefix:     ${prefix}
    bindir:          ${exec_prefix}/bin
    sbindir:         ${exec_prefix}/sbin
    libdir:          ${exec_prefix}/lib
    libexecdir:      ${exec_prefix}/libexec/apache
    mandir:          ${prefix}/share/man
    sysconfdir:      /etc/apache
    datadir:         /srv/www
    installbuilddir: ${libexecdir}/build
    errordir:        ${datadir}/error
    iconsdir:        ${datadir}/icons
    htdocsdir:       ${datadir}/htdocs
    manualdir:       ${datadir}/manual
    cgidir:          ${datadir}/cgi-bin
    includedir:      ${prefix}/include/apache
    localstatedir:   ${datadir}
    runtimedir:      /var/run
    logfiledir:      /var/log/apache
    proxycachedir:   /var/cache/apache/proxy
</Layout>
HERE_DOC
./configure --enable-layout=FHS --enable-mods-shared=all &&
make

This package does not come with a test suite.

Now, as the root user:

make install &&
chown -v root:root /usr/bin/{apxs,dbmmanage} \
  /usr/sbin/{apachectl,envvars{,-std}} \
  /usr/libexec/apache/httpd.exp \
  /usr/share/man/man1/{ab,apxs,dbmmanage,ht{dbm,digest,passwd,txt2dbm},logresolve}.1 \
  /usr/share/man/man8/{apachectl,htcacheclean,httpd,rotatelogs,suexec}.8 &&
chown -v -R apache:apache /srv/www

Also as the root user, optionally install the html docs:

mkdir -p /usr/share/doc/httpd-2.4.1/style &&
for thing in docs/manual/*.html.en
do
  tmp=${thing%.en}
  cp ${thing} /usr/share/doc/httpd-2.4.1/${tmp##*/}
done
cp -rf docs/manual/images /usr/share/doc/httpd-2.4.1 &&
cp -rf docs/manual/style/css /usr/share/doc/httpd-2.4.1/style &&
for directory in developer faq howto misc mod platform programs rewrite ssl vhosts
do
  mkdir -p /usr/share/doc/httpd-2.4.1/${directory}
  for thing in docs/manual/${directory}/*.html.en
  do
    tmp=${thing%.en}
    cp ${thing} /usr/share/doc/httpd-2.4.1/${directory}/${tmp##*/}
  done
done
sed -i \
  '/developer\|faq\|misc\|mod\|programs\|rewrite\|ssl\|vhosts/s#/"#/index.html"#' \
  /usr/share/doc/httpd-2.4.1/index.html

Command Explanations

--enable-mods-shared=all: The modules should be compiled and used as Dynamic Shared Objects (DSOs) so they can be included and excluded from the server using the run-time configuration directives.

chown root:root ...: This command changes the ownership of some installed files, the result of building the package as a user other than root.

chown -R apache:apache /srv/www: By default, the installation process installs files (documentation, error messages, default icons, etc.) with the ownership of the user that extracted the files from the tar file. If you want to change the ownership to another user, you should do so at this point. The only requirement is that the document directories need to be accessible by the httpd process with (r-x) permissions and files need to be readable (r--) by the apache user.

Configuring Apache

Config Files

/etc/apache/*

Configuration Information

The main configuration file is named /etc/apache/httpd.conf. Modify it so that the HTTP server runs as the dedicated user and group:

sed -i "s/daemon$/apache/" /etc/apache/httpd.conf

See /usr/share/doc/httpd-2.4.1/configuring.html for detailed instructions on customising your Apache HTTP server configuration file.

Boot Script

If you want the Apache server to start automatically when the system is booted, install the /etc/rc.d/init.d/httpd init script included in the blfs-bootscripts-201205011 package.

make install-httpd

Contents

Installed Programs: ab, apachectl, apxs, checkgid, dbmmanage, htcacheclean, htdbm, htdigest, htpasswd, httpd, httxt2dbm, logresolve and rotatelogs
Installed Directories: /etc/apache, /srv/www, /usr/include/apache and /var/log/apache.

Short Descriptions

ab

is a tool for benchmarking your Apache HTTP server.

apachectl

is a front end to the Apache HTTP server which is designed to help the administrator control the functioning of the Apache httpd daemon.

apxs

is a tool for building and installing extension modules for the Apache HTTP server.

checkgid

is a program that checks whether it can setgid to the group specified. This is to see if it is a valid group for Apache2 to use at runtime. If the user (should be run as superuser) is in that group, or can setgid to it, it will return 0.

dbmmanage

is used to create and update the DBM format files used to store usernames and passwords for basic authentication of HTTP users.

htcacheclean

is used to clean up the disk cache.

htdbm

is used to manipulate the DBM password databases.

htdigest

is used to create and update the flat-files used to store usernames, realms and passwords for digest authentication of HTTP users.

htpasswd

is used to create and update the flat-files used to store usernames and passwords for basic authentication of HTTP users.

httpd

is the Apache HTTP server program.

httxt2dbm

is used to generate DBM files from text, for use in RewriteMap.

logresolve

is a post-processing program to resolve IP-addresses in Apache's access log files.

rotatelogs

is a simple program for use in conjunction with Apache's piped log file feature.

Last updated on 2012-03-05 15:41:10 +0000