Building and installing Apache 2 on a Mac

Ok Below is a rough guide to get anyone up and going when it comes to building and installing Apache 2 from source. We're gonna do this all from the Terminal found in /Applications/Utilities/Termain.app.

Please note that '$' means new line, don't type this character If you want to know about any of the commands we make from the terminal you can always type "man + command" e.g.

$ man curl
If you run the above code it should tell you that
curl is a tool to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, GOPHER, DICT, TELNET, LDAP or FILE). The command is designed to work without user interaction.

This will also detail the options I use.

1: Download Apache 2 from source. Now you can do this from the browser by simply going to http://httpd.apache.org/ but where is the fun in that :o) From the Termainal type:

$ curl -O http://www.eu.apache.org/dist/httpd-2.2.0.59.tar.gz
$ gnutar -xzf httpd-2.0.59.tar.gz

2: Building
Our installation of Apache2 is going to be stored on the root i.e. /apache2

$ cd httpd-2.2.2
$ sudo ./configure --prefix=/apache2

3: Installing

$ sudo make
$ sudo make install

4: Starting and Stopping Apache 2 Apache 2 should now be installed.

To start Apache 2:

$ sudo /apache2/bin/apachectl start

To restart Apache 2:

$ sudo /apache2/bin/apachectl restart

To stop Apache 2:

$ sudo /apache2/bin/apachectl stop

That's all you need to get it installed. Once you are at this point the next move is to edit the httpd.conf file, which you can find at /apache2/conf/httpd.conf

Comments (7) Print Send del.icio.us Digg It! Linking Blogs

2357 Views | Posted At : June 12, 2007 1:15 AM | Posted By : Andy Jarrett
Related Categories: apache, Mac, Rough Guide

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)

Nathan Mische's Gravatar I found the following very helpful when I was building Apache from source on the Mac.

http://www.devshed.com/c/a/Apache/Building-Apache-...
# Posted By Nathan Mische | 6/12/07 12:44 PM
Ulf's Gravatar Hi Andy,

how did you connect Coldfusion MX 7.02 to your new Apache 2.2 - that failed for me so I switched back to included Apache 1.3...

If you get it to work, maybe you post a step by step tutorial, that would be great.

Thanks.

Ulf
# Posted By Ulf | 6/12/07 11:36 PM
doug's Gravatar Hey Andy,
I am running into a roadblock:
configure: error: no acceptable C compiler found in $PATH
following step 2 after configure
I have been trying to find a gcc but all I cant find a binary (don't have a compiler (-:).
Any thoughts??
D.
# Posted By doug | 9/1/07 8:29 AM
Andy Jarrett's Gravatar @doug silly question, you on a mac? if so which version? You might want to try the following command in the Terminal: "echo $PATH" (without the quotes)

if so what does that return?
# Posted By Andy Jarrett | 9/3/07 11:18 PM
doug's Gravatar Andy, not silly at all -- I am on a mac, converted one week ago (not completely weaned off of my Win box yet). I have a 13" MacBook running 10.4.10. Trying to install Apache from source.

Here is the return from echo $PATH:
/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin

Here is the entire transcript from Terminal:

Dougrs-Computer:~ dougr$ curl -O http://apache.mirrors.tds.net/httpd/httpd-2.2.4.ta...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6216k 100 6216k 0 0 654k 0 0:00:09 0:00:09 --:--:-- 641k
Dougrs-Computer:~ dougr$ gnutar -xzfhttpd-2.2.4.tar.gz
Dougrs-Computer:~ dougr$ cd httpd-2.2.4
Dougrs-Computer:~/httpd-2.2.4 dougr$ sudo ./configure --prefix=/apache2
Password:
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking build system type... i386-apple-darwin8.10.1
checking host system type... i386-apple-darwin8.10.1
checking target system type... i386-apple-darwin8.10.1

Configuring Apache Portable Runtime library ...

checking for APR... reconfig
configuring package in srclib/apr now
checking build system type... i386-apple-darwin8.10.1
checking host system type... i386-apple-darwin8.10.1
checking target system type... i386-apple-darwin8.10.1
Configuring APR library
Platform: i386-apple-darwin8.10.1
checking for working mkdir -p... yes
APR Version: 1.2.8
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
configure failed for srclib/apr
Dougrs-Computer:~/httpd-2.2.4 dougr$ echo $PATH
/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin
Dougrs-Computer:~/httpd-2.2.4 dougr$

Pretty much crying for a compiler eh?
D.
# Posted By doug | 9/4/07 6:24 AM
doug's Gravatar Looks like this is related to my not having everything installed that I need from my install disc. I received this machine from work and found out this morning that the developer tools from the install disk had not been installed. This machine actually was the owners who was running Win from bootcamp and never used the Mac side at all. Anyway, I will look into that today- I bet that will solve the issue because GCC is part of the install.
D.
# Posted By doug | 9/4/07 5:09 PM
dougrdotnet's Gravatar Hey Andy-That was it!
Thanks,
dougrdotnet
# Posted By dougrdotnet | 9/5/07 3:15 AM