I run a third party PHP application on my local AMP stack on my Mac. I recently bought a new Mac Mini with Lion, and am trying to set it up. My previous computer was a MB air with MAMP. Now I’m using the built-in apache/php and a homebrew installed MySQL.
Here’s my problem: I have a directory with symbolic links. These symlinks are to directories, and the PHP application is checking these with is_dir().
On my Lion AMP setup, this is_dir() is failing. The same setup on my Snow Leopard MAMP is_dir() works fine with my symlinks.
Here’s where it gets more curious. If I do php -a (php interactive command line mode), and do is_dir() on the very same directories, it returns true. It only returns false in the context of an apache request. This makes me think it has something to do with the apache user (which is _www) not being able to access the symlinks. Troubleshooting this falls outside of my expertise.
Other notes:
- Yes, I have
FollowSymLinksturned on in my apache config, and in
fact, the directory where the symlinks in question reside is a
symlink itself. Apache has no problem with it. Until PHPis_dir()is
used. - No, I cannot edit the PHP application and just fall back on
is_link()
andreadlink(). - This exact same setup worked on my Snow Leopard/MAMP setup.
Any ideas?
Ah saw your comment on changing them to
777but still wondering why it’s not working.My solution below might not help you.
EDIT:
If you have access to
/etc/apache2/httpd.conf,edit it via
sudo vi /etc/apache2/httpd.conf.Then change these 1 of these lines or both of them
Here is an example of my directory listing.
Now my public directory has
775permissions, meaningownerandgrouphave full permissions while other users can only read and execute.It depends if you want apache user to become
acefrom the default_wwwor the apache group to becomestafffrom the default_www.Once you’ve decided on which to change, restart apache.
And your page should now have access to the directories / files.
One thing to note is that you have to change ownership for files that have been already been written by your webpage as those have
_www:_wwwownership and you won’t have access to them after the restart.You can change their new ownership through this,
-Ris to make it recursive.