alistairphillips.com

I’m : a web and mobile developer based in the Manning Valley, Australia.


Apache2 on Mac OS X Leopard

With Mac OS X being based on *nix you have access to all of the standard goodies that you'd expect from your Linux distribution of choice. Apache 2.2.9 is included with Leopard 10.5.6. If you'd like to configure a virtual host open up /private/etc/apache2/extra/httpd-vhosts.conf and use the following for a template:

<VirtualHost *:80>
    ServerName journal
    DocumentRoot "/Users/alistair/Zend/workspaces/DefaultWorkspace/journal/public"
    <directory "/Users/alistair/Zend/workspaces/DefaultWorkspace/journal/public">
        Options Indexes MultiViews Includes FollowSymLinks
        AllowOverride All
        Order allow,deny
        allow from all
    </directory>
</VirtualHost>

It's the AllowOverride All that enables .htaccess support

The important bit here is the element as it will prevent the 403 error of client denied by server configuration which would otherwise be generated.

SSL Access

Enabling SSL access can be done with the following steps:

1 - Generate a server key
openssl genrsa -des3 -out server.key 4096

2 - Create a certificate signing request with the server key
openssl req -new -key server.key -out server.csr

3 - Sign the certificate signing request
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

4 - Remove the password from server.key
openssl rsa -in server.key -out server.key.insecure
mv server.key server.key.secure
mv server.key.insecure server.key

Now copy server.crt and server.key into /private/etc/apache2/ Open up httpd.conf and remove the # from Include /private/etc/apache2/extra/httpd-ssl.conf

Restart!

Use Apache virtual hosts outside the Sites folder

1 - Set up your virtual host with ~/Documents/any/sub/folder/ as the document root.
2 - Add yourself to the www group: sudo dscl localhost append /Local/Default/Groups/www GroupMembership _username_ -- replace _username_ with your user's short username.
3 - chgrp www ~/Documents
4 - chmod 750 ~/Documents