Tutorial: Install Apache 2.0 on Tiger, part 2 of 2

ApacheIn part one of this tutorial we installed Apache 2 using a pre-built installer package graciously provided by Server Logistics. But if you need the latest version, some more Apache modules, or a little more customization in your installation, you'll have to build and install from source. That always sounds scarier than it actually is, so if you're not uncomfortable with some tinkering in Terminal, you'll have Apache 2 built and installed before you know it -- it really is quite easy!

Technorati Tags: , , ,

Prerequisite: You'll need to install Apple's Developer Tools (included in your Applications folder, or on a CD that came with your Mac) to get the necessary compiler software onto your system.

First, start the Terminal application. You'll be in your home directory, and we want to create a temporary directory in which to download and build the Apache source code:

mkdir src
cd src

Now we'll use the curl program to download the source from the web using the command line:

curl -O http://apache.mirrors.esat.net/httpd/httpd-2.0.54.tar.gz

And unzip it (if you wanted, you could just as easily use Stuffit expander to expand this file, but it's good to not always have to rely on a third party application):

tar xzf httpd-2.0.54.tar.gz

This will create a new directory called "httpd-2.0.54" and unpack the contents of the archive to it. Change to this directory:

cd httpd-2.0.54

Now you need to decide where on your disk Apache 2 will live. A good convention is to put Unix software that you install (i.e., not Mac-specific software that would go in your "Applications" folder) in the /usr/local directory. Let's do that, and put Apache in /usr/local/apache2.

You will run the "configure" command (included with the Apache source code you just downloaded) to set this directory, and to set the other default settings that will be used by the compiler. The --enable-so and --enable-mods-shared=all will install all of the Apache modules included in the source distribution. This configuration will give you the most flexibility for a development server:

./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all

The configure script will take a little while to check that your system is able to compile Apache. If it fails, you most likely do not have Apple's Developer Tools tools installed. Be sure to do that, as the developer tools contain the compiler program necessary to build the source code.

Now it's time to actually compile the source code. This will probably take several minutes:

make

When it's done, Apache will be compiled and ready to install. you need to use the "sudo" command if we're installing Apache where the root user only has permission to write files (like /usr/local/apache2). It will ask for your password.

sudo make install

That's it! Apache is now installed at /usr/local/apache2. Make sure you stop any other version of Apache that's running (uncheck "Personal Web Sharing" in System Preferences -> Sharing), and start Apache 2:

sudo /usr/local/apache2/bin/apachectl start

And if you point your browser at http://localhost, you should see the Apache start page. This is located at /usr/local/apache2/htdocs, so you can feel free to edit or replace those files with your own HTML. Your new Apache 2 configuration file lives at /usr/local/apache2/conf/httpd.conf. It's well-commented, so feel free to open it up and look through it, though you will want to make sure you know a little about this configuration file before making any changes to it.

I hope that went well, and you now have a working installation of Apache 2.0.54 on your Mac. Please leave a comment here if this was helpful, or if you had any trouble at all, and I'll do my best to help you out!

by frank on Jul 21, 05 09:23 PM

Trackback Pings

TrackBack URL for this entry:
http://www.macpot.com/cgi-local/mt/mt-tb.cgi/82