Installing apache on Mac OS X

I’ve got Leopard (10.5.1) with the developer tools installed and want to do some
more development in Django on my laptop. I first want to install MacPort to make it
easier to download and install various opensource projects. Using MacPorts, I’ll
get Apache
installed and configured. Finally, I’ll get the basic django working.
1. Installing Mac Ports painless. Just follow the direction at the web site. I prefered to download and install the disk image: disk image
2. You need to add port to your path. I use a ~.bashrc:

PATH=/usr/local/bin:/usr/X11R6/bin:/opt/local/bin:/opt/local/sbin:$PATH
    

and make sure it’s available (create a new shell, a new terminal window, or “. ~/.bashrc”). The command

bport -h/b
Usage: port
        [-bcdfiknopqRstuvx] [-D portdir] [-F cmdfile] action [privopts] [actionflags]
        [[portname|pseudo-portname|port-url] [@version] [+-variant]... [option=value]...]...
"port help" or "man 1 port" for more information.
    

should print a help message.
3. I checked to make sure which apache and any options I could chose from (the “sudo” is so I can run the command as root (administrative user) and I do it each time so I have a log of my actions)

$ sudo port selfupdate
MacPorts base version 1.600 installed
Downloaded MacPorts base version 1.600
The MacPorts installation is not outdated and so was not updated
selfupdate done!
$ sudo port list apache
apache                         @1.3.37         www/apache
macbook:~ ware$ sudo port list apache2
apache2                        @2.2.6          www/apache2
$ sudo port variants apache
apache has the variants:
	universal
	darwin
	apache_layout

And finally, let’s install it:

$ sudo port install apache2

Shockingly, there was an error:

...
checking for mawk... (cached) no
checking for gawk... (cached) no
checking for nawk... (cached) no
checking for awk... (cached) no
configure: error: No awk program found
  

I think there was a path problem involved because gawk was now installed and restarting the install worked:

$ sudo port install gawk
Skipping org.macports.activate (gawk ) since this port is already active
$ sudo port install apache2
  

I now need to tell OS X about starting up this application on system booting:

$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
  

And now it’s time to configure apache:

$ cd /opt/local/apache2/conf
$ cp httpd.conf.sample httpd.conf
   

Trying to start it apache up gave me this error:

$ sudo /opt/local/apache2/bin/apachectl start
httpd: Syntax error on line 96 of /opt/local/apache2/conf/httpd.conf: Cannot load /opt/local/apache2/modules/mod_ssl.so into server: dlopen(/opt/local/apache2/modules/mod_ssl.so, 10): Symbol not found: _ssl_cmd_SSLCACertificateFilen  Referenced from: /opt/local/apache2/modules/mod_ssl.son  Expected in: flat namespacen
   

Use your favorite editor to comment out ssl (I don’t need it, yet)

$ sudo vi httpd.conf
...
#LoadModule ssl_module modules/mod_ssl.so
...

3. Start it up:

$ sudo /opt/local/apache2/bin/apachectl start
$ sudo bin/apachectl start
 

4. And prove it works by connecting to http://localhost/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.