I enable "WebSharing" and use http://localhost/~dmuey/ for development purposes.

I want to run CGI as the user but for some reason Apple does not ship suexec with their Apache.

For a while the Apache included with OS X was so old you could no longer find the source anywhere on the internet in order to build your own, but now that they've updated to 2.2 it's a little easier:

  1. What version of Apache do you have?

    /usr/sbin/httpd -v

  2. Download that version from http://httpd.apache.org/

    I have 2.2.17 ATM so I find the current 2.2 URL (2.2.19) and change it to match the version I have

  3. tar xzf httpd-2.2.17.tar.gz && cd httpd-2.2.17
  4. ./configure --enable-layout=Darwin --enable-suexec --with-suexec-caller=_www --with-suexec-docroot=/ --with-suexec-userdir=Sites
  5. make
  6. sudo cp support/suexec /usr/bin/
  7. sudo chown root:_www /usr/bin/suexec
  8. sudo chmod 4750 /usr/bin/suexec
  9. edit  /private/etc/apache2/httpd.conf
    1. Uncomment AddHandler cgi-script .cgi
    2. Add .pl .perl to the list
    3. Find  DirectoryIndex index.html 
    4. Add these to the list index.cgi index.pl index.perl
  10. sudo apxs -i -a -c modules/generators/mod_suexec.c
  11. sudo apachectl stop && sudo apachectl start

Trouble shooting:

Nothing seems to have changed:

 check the path you used is the one Apache wants :: /usr/sbin/httpd -V |grep suexec

error_log :: [2009-05-06 15:01:34]: user mismatch (www instead of _www)

recompile with the user it wants