Installing Apache

One of the most popular websevers in the world. You can download it from, but you probably don't need to because it is included with most current versions of OS X. Check to see if you have a directory /etc/apache2/ and, specifically, the file /etc/apache2/httpd.conf. If you do, you're nearly ready to go.

The current version of Apache is 2.4.18 (Feb 2016). The upgrade from 2.2 to 2.4 featured several changes in the standard Apache configuration; see below under "Installation hitches" for more.

Apache's main execution form is its HTTP daemon, httpd. "Apache" and "httpd" are sometimes used interchangeably.


STEP 1) Within the main Apache configuration file /etc/apache2/httpd.conf, look for the line that begins with ServerName. If it's commented, uncomment it and set it to

ServerName localhost

This tells Apache to identify your local installation as "localhost". When you're done with the rest of the setup, you'll be able to open your local copy of the site in your browser as the address "localhost".

Proxy Modules

Apache is modular, meaning that you have to "activate" certain functionality by enabling additional modules beyond the basic installation. In httpd.conf, you'll find a large block of lines that begin with LoadModule. Each line identifies an Apache module; uncommented lines are enabled modules, while commented lines are disabled.

When we install Tomcat, we'll want it to act as a proxy for Apache. This means that we have to enable Apache modules for proxying via AJP (Apache JServ Protocol).

STEP 2) In httpd.conf, make sure the lines

LoadModule proxy_module libexec/apache2/

LoadModule proxy_ajp_module libexec/apache2/

are uncommented. This enables the modules proxy, which provides Apache with general proxying capabilities, and proxy_ajp, which implements the AJP proxy scheme specifically.

Note: If you're using Debian-style Apache (i.e., if your local machine runs Debian, Ubuntu or Mint Linux), you'll need to enable these modules through the command line. See the Using Apache page for more information.

Configuring AJP

STEP 3) At the end of httpd.conf, add the line

Include /private/etc/apache2/other/*.conf

This tells Apache to include any further configuration directives specified in any files ending in .conf found in the directory other/.

In general, you don't want to tinker with httpd.conf once you've got your server's basic settings in place, so additional configuration options should go in separate files. For the sake of good organization, we'll call these files <whatever>.conf and keep them in their own directory. For the moment, though, the only thing we want to additionally configure is AJP.

STEP 4) Create the directory /apache2/other/ and a file ajp.conf inside it. Configuration syntax is another thing that changed starkly between Apache 2.2 and Apache 2.4; if you're using Apache 2.2 or lower, copy this into ajp.conf:
ProxyRequests Off
<Proxy *>
    Order deny,allow
    Deny from all
    Allow from localhost
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/

If you're using Apache 2.4, copy this into ajp.conf:
ProxyRequests Off 
<Proxy *>
    Require host localhost
ProxyPass / ajp://localhost:8009/ 
ProxyPassReverse / ajp://localhost:8009/

The language here is a special "Directives" syntax used for Apache configuration directives. You can learn more about them here: These are important. In either form, they tell Apache that only localhost - the ServerName you assigned to your machine in httpd.conf - is allowed to use Apache as a proxy. This keeps any other computer able to connect to yours from using your Apache installation as a proxy through which to do nefarious things, or from viewing your local copy of the website.

Installation hitches

Something we ran into on Mac OS X:

OS X Yosemite was the first Mac OS to ship with Apache 2.4; earlier versions shipped with Apache 2.2. This upgrade involved important changes in some of the standard modules. If you upgraded to Yosemite (or later) from an earlier version of OS X, then your httpd.conf file probably did not get altered in the process. Thus, your httpd.conf will try to load outdated modules into Apache 2.4, which will throw an error of the form

httpd: Syntax error on line 59 of /private/etc/apache2/httpd.conf: Cannot load libexec/apache2/ into server: dlopen(/usr/libexec/apache2/, 10): image not found

( is one of the modules that changed between Apache 2.2 and 2.4).

The best way around this is to copy httpd.conf from another developer who's working on OS X 10.10 (Yosemite) or higher.

As a side note, you can check which version of Apache you're running with apachectl -v.

-- Main.jgriffith - 2016-03-03
Topic revision: r2 - 2016-03-11, jgriffith
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback