Tuesday, August 2, 2011

Apache 2.2 / PHP 'Broken' in Leopard

Still unclear if this was 'broken', or if Apple intended on this strange behavior, but after performing an Archive and Install of Leopard, was unable to access any sites within my "~/Sites" directory, for the first time ever, with the error message:

"Apache error message: "Forbidden - You do not have permission"

This issue does NOT surface if you perform an Archive / Install with the option "Preserving Users and Preferences". After five concurrent "10.5.x" updates without a fix, I finally decided to tackle it, because Apple sure didn't seem be offering any Mea Culpas, nor any explanations for their reasons for 'commenting out' (#) at least 2 key lines within "httpd.conf" config file. Here's the solution (or, ONE solution, at least):

Kill Apache Web Server (either from System Prefs > Sharing > Web Serving, and uncheck box), or, in Terminal, type: 

$/usr/sbin/apachectl stop

Pico, vi (or whatever your favorite c.l.i. text editor is), and open "private/etc/apache2/httpd.conf'".
Locate the line that reads #LoadModule php5_module libexec/apache2/libphp5.so"
UN-comment out (remove the '#' preceding this line), save and exit out of the session.
Restart Apache (System Preferences > Sharing > Web Serving, and CHECK the checkbox), or in Terminal type:
        $/usr/sbin/apachectl start
Note: I was surprised to find many forum entries that simply suggested changing permissions recursively for the directory /private/etc/apache2/. While some posted that this worked, it is not recommended.

Followers

about me

10 Years in Advertising (Account Exec), and 14 Years in I.T./System Administration (multi-platform, but specializing on the Mac platform).