Mac OS X ~/Library permissions

by Michael Alderete on 4/22/2003

Before I explain the problem and solution that had me tearing my hair out Friday through Sunday, let me explain how I organize my system for doing PHP development and serving. Mac OS X Jaguar includes robust web serving capabilities, in the form of Apache and PHP. Apache’s default services, the documents and CGIs which are installed with Jaguar, are located in subdirectories under /Library/WebServer. This would be a natural place to put configuration and include files for PHP, and indeed it is where I keep the server-wide php.ini configuration file for PHP:


(I also create a symlink for that file at /usr/local/lib/php.ini, because that’s where Marc Liyanage’s full-featured PHP module, which I install over Apple’s “lite” version, expects to find its configuration file.)

However, Mac OS X separates out very cleanly the functionality installed at the system level, for all users, and functionality installed for a specific user. System level items go into /Library, while user-specific items go into ~/Library (that is, the Library folder in your home folder). The two directories mirror each other in structure, but have a different “scope” — system-wide versus user-specific. Since I was adding my blogging system‘s PHP libraries for my own use only, I created the ~/Library/WebServer directory, and a PHP/Includes subdirectory under it, to hold them:


I add the following line to my /private/etc/httpd/users/username.conf to make PHP look for include files in the above Includes folder:

path "/Users/username/Library/WebServer/PHP/Includes:/Library/WebServer/PHP/Includes"

This needs to go inside a VirtualHost or Directory statement; if you don’t know what those are, you might not want to be fiddling with this stuff.

The problem was, whenever I would load a PHP page that tried to include() one of the PHP libraries, or any file stored in my private Includes folder, it would fail with a “file not found” error. I spent more than 6 hours trying to track this problem down, finally resorting to brute force PHP scripts to test file_exists() on a bunch of different files, until I located the issue (and was able to blog once more!).

So, finally, here’s my point. Note to future self: the next time you re-install Mac OS X from scratch, remember that the reason why PHP cannot access include files in your ~/Library/WebServer folder is because the permissions on the ~/Library directory forbid read access to all but owner. You need to increase the permissions like this:

% chmod go+r ~/Library

Remember it!

Previous post:

Next post: