My Site

Installing Apache 2.2.4

Working for various clients and deploying a full working rails stack on their hardware and environments is not always as straight-forward and easy as it should be. What distribution are they using? Which package manager? Does the package manager even currently have the right versions I need? So over the coming days I'm going to write a few tutorials on getting the latest software, from source, and compiling it. So intro today, with Apache.

The only assumption I make is that gcc is available on the system so the we can compile the source into binaries. If you don't have it, you'll need to install it for your system. So the first thing to do is download the latest unix source from a local mirror and save it somewhere convenient. To make life easier, I'm going to download all the files directly to the server using wget. So it's simply a matter of:

mkdir rails-setup
cd rails-setup

<p>But before we get too far ahead of ourselves, I know that I'm going to want to add in the ability to compress output I'm sending back to the end user, as well as support for <span class="caps">HTTPS</span>/SSL. So I'm going to need those libraries too. Lets go get them:</p>

And tada! We've hopefully got all we need. Time to compile.

tar zxf zlib-1.2.3.tar.gz 
cd zlib-1.2.3
./configure --prefix=/usr/local
make; sudo make install; make clean;
cd ..

<p>So what have we just? We've grabbed the <a href="">zlib</a> tarball and extracted and decompressed it into it's own directory. We then go in there, and run <em>./configure</em> to ensure it is setup for our environment. Then we run make, install it once it's done, and then clean up the leftovers.</p>

<p>Time to do the same with <a href="">OpenSSL</a>.</p>
tar zxf openssl-0.9.8e.tar.gz
cd openssl-0.9.8e
./config --prefix=/usr/local
make; sudo make install; make clean;
cd ..

<p>Okay, now we should be ready for Apache. Here's the next series of commands I typically run:</p>
tar zxf httpd-2.2.4.tar.gz
cd httpd-2.2.4
./configure --enable-mods-shared=all --enable-proxy --enable-proxy-balancer --enable-proxy-http --enable-rewrite --enable-cache --enable-headers --enable-ssl --enable-deflate --with-included-apr --with-ssl=/usr/local/ssl --prefix=/usr/local/apache2
make; sudo make install; make clean;
cd ..

<p>So what we've done is run the configure script to set things up for the current environment, letting make know that we want to enable</p>


  • Mod proxy (so we can send requests through to mogrel/rails)
  • Mod proxy balancer (so that we can distribute to various mongrel instances)
  • Enabled proxy support (need it to pass requests to mod proxy)
  • Turn on URL re-writing (so we can handle rails routing)
  • Enable dynamic file caching
  • Let us take control of the HTTP headers
  • Turn on support for SSL/TLS (nice and secure)
  • Turn on support for deflate transfer encoding (helps keep the transfer size down)
  • The location of the OpenSSH installation
  • The location where we want to install Apache
  • It will then run through, compile all the code, install it on the server, and clean up it's mess it might have left behind.

    <p>And there you have it! Apache is setup, and should be working and running on your server. Over the coming days I'll post further instruction on getting the rest of the stack running. That is going to entail MySQL and/or Postgres, ruby, rails, mongrel, mongrel_cluster, and monit for managing the services and starting/stopping everything. And of course, the various configuration that is required to make it all talk together.</p>
    <p>You could also delete the files we downloaded and the directories we installed from because our work here is done. I personally keep them around at least until everything is working together and the system is stable, but it's up to you.</p>

    Glenn Gillen

    I'm an advisor to, and investor in, early-stage tech startups. Beyond that I'm an incredibly fortunate husband and father. I'm currently a Product Manager at HashiCorp. Previously at AWS and Heroku.

    Working on a developer-facing tool or service? Thinking about starting one? Email me and let me know