Home > Articles

This chapter is from the book

Installing Apache on Unix

This section explains how to install Apache on Unix and Unix-like systems such as Solaris, Linux, and FreeBSD.

Checking Whether Apache Is Already Installed in Your System

If you are running a modern Linux distribution, chances are that Apache is already installed in your system. Try the following at the command-line prompt:

# httpd -v

Because some distributions name the Apache binary httpd2, you can also try the following:

# httpd2 -v

If Apache is installed and the binary is in your path, you will get a message with the version and build time:

Server version: Apache/2.0.28
Server built:  Dec 29 2001 10:32:01

Otherwise, you will get command not found or a similar message. It might be that Apache is already installed but is in a different path or with a different binary name, such as httpd2. Check whether /usr/local/apache2/ or /etc/httpd2 exists and contains a valid Apache 2.0 installation.

This books covers Apache 2.0, so you must make sure that this is the version installed in your server. An existing 1.3 Apache installation is likely to interfere with your new Apache if the older installation runs at startup. Make sure that either the package is removed from the operating system or the startup script, if any, is disabled. For example, in most Linux distributions, this means modifying the startup scripts at /etc/rc.d/. Apache 1.3 and 2.0 can coexist and run simultaneously if they use different IP address and port combinations, as explained in Hour 4.

If Apache 2.0 is already installed in your system, you can skip the following sections and go directly to Hour 4, "Getting Started with Apache." You can always read this hour later if you decide to build your own server.

Installing from Source

The steps necessary to successfully install Apache from source are

  1. Downloading the software

  2. Running the configuration script

  3. Compiling the code and installing it

These steps are described now in detail.

Downloading the Apache Source Code

The official Apache download site is located at http://www.apache.org/dist/httpd. You can find several Apache versions, packaged with different compression methods. The distribution files are first packed with the Unix tar utility and then compressed either with the gzip tool or the compress utility. Download the .tar.gz version if you have the gunzip utility installed in your system. This utility comes installed by default in open source operating systems such as FreeBSD and Linux. Download the tar.Z file if gunzip is not present in your system, such as in the default installation of many commercial Unix operating systems.

NOTE

The gzip, gunzip, and gtar programs are useful tools. The Gzip Web site at http://www.gzip.org provides you with links to the source code and binaries for Unix platforms such as Solaris, AIX, and HP-UX. If gunzip is not installed but gzip is available in your system, you can use gzip -d instead.

The file you want to download will be named something similar to httpd-2_0_version.tar.Z or httpd-2_0_version.tar.gz where version is the most recent release version of Apache.

Uncompressing the Source Code

If you downloaded the tarball compressed with gzip (tar.gz suffix), you can uncompress it using the gunzip utility (part of the gzip distribution).

NOTE

Tarball is a commonly used nickname for software packed using the tar utility.

You can uncompress and unpack the software by typing the following command:

# gunzip < httpd-2_0*.tar.gz | tar xvf -

If you downloaded the tarball compressed with compress (tar.Z suffix), you can issue the following command:

# cat httpd-2_0*.tar.Z | uncompress | tar xvf -

Uncompressing the tarball creates a structure of directories, with the top-level directory named httpd-2.0_version. Change your current directory to the top-level directory.

Configuring the Software

You can specify which features the resulting binary will have by using the configure script, in the top-level distribution directory. By default, Apache will be compiled with a set of standard modules compiled statically and will be installed in the /usr/local/apache2 directory. If you are happy with these settings, you can issue the following command to configure Apache:

#./configure

For the remainder of the book, it is assumed that you compiled Apache with loadable module support and built most of the modules as such. This, combined with the Apache extension utility (apxs), will enable you to extend the server later with third-party modules without the need to recompile, as described in Hour 18.

To configure Apache this way, issue the following command:

#./configure --enable-so --enable-mods-shared=most

If you are installing Apache as a normal user and you don't have write permissions on /usr/local/, or you simply want to install Apache on a different location, you can specify an alternative location using the --prefix option. For example, the following line:

#./configure --enable-so --enable-mods-shared=most
 --prefix=/home/username/apache2

will compile Apache to be installed in the home directory of the username user.

The purpose of the configure script is to figure out everything related to finding libraries, compile time options, platform-specific differences, and so on, and to create a set of special files called makefiles. Makefiles contain instructions to perform different tasks, called targets, such as building Apache. These files will then be read by the Unix make utility, which will carry on those tasks. If everything goes well, after executing configure, you will see a set of messages related to the different checks just performed and you will be ready to compile the software.

Compiling and Installing Apache

The make utility reads the information stored in the makefiles and builds the server and modules. Type make at the command line to build Apache. You will see several messages indicating the compilation progress. After compilation is finished, you can install Apache by typing make install. The Apache distribution files will be copied to /usr/local/apache2 or the target directory specified with the --prefix switch.

Apache Compilation Options

The Apache configuration script, configure, can take additional options. Many of them are irrelevant for most users, either because they are rarely used or they relate to building Apache distribution packages. A number of them deal with enabling or disabling specific modules, and those are explained in detail in Hour 18. Table 3.1 describes the most useful configuration options. You can get a complete listing by issuing the ./configure --help command.

Table 3.1 Configuration Options

--with-mpm=mpm

Specifies the Apache Multi-Processing Module. If this option is not specified, the default MPM for the platform will be compiled in. In Unix, the value for mpm can be either worker, perchild, or prefork. MPMs are discussed in Hour 11, "Multi-Processing Modules."

--enable-so

Enables loadable module support.

--prefix=path

Apache will be installed relative to the value of the path directory. By default, Apache will be installed in /usr/local/apache2.

--enable-module
--disable-module

Enables or disables the specified module. Check Hour 18 for a complete module listing and descriptions.

--enable-modules=list
--enable-mods-shared=
list

Another way of specifying which modules to build, either compiled into the server or as shared libraries. Both switches can take either a list of modules, all (all modules bundled with Apache), or most (includes the majority of the modules you will need).


Selecting the Appropriate MPM

Hour 11 explains the role of Multi-Processing Modules. Table 3.2 shows the relationship between platforms and MPMs.

Table 3.2 MPMs and Platforms

Platform

Available MPMs

Windows NT/2000/XP

winnt

BeOS

Beos

OS/2

mpmt_os2

Linux

worker, prefork (default), perchild

Solaris

worker, prefork (default), perchild

HP-UX

worker, prefork (default), perchild

AIX

worker (recommended), prefork (default), perchild

Mac OS X

worker, prefork (default), perchild

FreeBSD

worker, prefork (default), perchild

Cygwin

prefork (default)


In the Windows, BeOS, and OS/2 platforms, there is no choice of MPM and the appropriate one will be selected. In Unix platforms, the default is the prefork MPM, although the worker MPM is probably a better choice, except for some platforms such as FreeBSD. The Cygwin platform supported only the prefork MPM at the time this book was being written. Table 3.2 gives you information about which MPM modules are available for a specific platform. Further information on which MPM to choose, their advantages and disadvantages can be found in Hour 11.

Installing Binaries

This section explains how to install a pre-built Apache server on Unix platforms.

Binaries from the Apache Web Site

You can download binaries for different platforms from the Apache Web site at http://www.apache.org/dist/httpd/binaries. Check whether binaries for your platform are available. You can download and uncompress the tarball as described in the previous section. In this case, the configuration and compilation steps are not necessary. You can install the software by executing the install-bindist script. You can pass an optional argument, the target installation directory. Otherwise, the software will be installed in /usr/local/apache2.

Distribution-Specific Packages

Operating system vendors recognize that Apache is an important server software component and either include it by default or make it available in a distribution-specific format.

For Linux distributions based on the RPM format, you can query whether Apache 2.0 is already installed by issuing this command:

#rpm -q apache2 

If Apache 2.0 is not available, you can go to the distribution vendor Web site, download the Apache 2.0 RPM, and install it executing the following command as root:

#rpm -i apache2*.rpm

Apache 2.0 is part of the FreeBSD and other BSD flavors ports collection. Just change to the appropriate directory and type make install. That command will download the source code, and build and install the server.

You can get Apache binaries and packages for Solaris platforms at http://www.sunfreeware.com. Solaris 8 already bundles an Apache 1.3 version, and future releases will likely include Apache 2.0.

Building from CVS

CVS stands for concurrent versioning system and is a popular software development tool that enables programmers to simultaneously work on the same code base, keeping track of changes and revisions and helping to resolve conflicts in the code. Apache is an open source project and makes the source code available via a public CVS server. You can check out any particular release of the code or the latest, unreleased version this way. Compiling and building from CVS is an advanced topic and not recommended for beginners. The following sections comprise a step-by-step guide to compiling Apache from CVS.

The CVS Client

You need the cvs command-line utility to connect to the Apache CVS repository. It is available by default in most Linux distributions and other open source operating systems such as FreeBSD. If cvs is not available for your system, check your vendor package repository or download and compile the source from http://www.cvshome.org.

Checking Out the Source

The main Apache CVS repository is at cvs.apache.org. The first step will be to log in to that server:

# cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login

You will be prompted for a password; use anoncvs.

To retrieve the Apache source code (check out the code in the jargon), issue the following command:

# cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic co httpd-2.0

The httpd-2.0 directory that contains the Apache source code will be created. The packaged source tarball for Apache includes a couple of libraries that are not present in CVS apr and apr-util. Change your directory to httpd-2.0/srclib/ and execute the following commands:

# cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic co apr
# cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic co apr-util

Building the configure Script

You need to change your current directory to httpd-2.0 and execute the ./buildconf command. That will create a configure script. From this step on, you can follow the instructions in the "Building Apache from Source" section earlier in the hour. The buildconf script requires the autoconf utility, which is either already included with your system or can be downloaded from http://www.gnu.org/software/autoconf.

Check Out a Specific Version of Apache

You can check out a specific version of Apache by using the -r tag option to the cvs command-line utility. For example, this line

# cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic
  co -r APACHE_2_0_28 httpd-2.0

will check out the source code for Apache 2.0.28.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020