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:
FollowSymLinks
turned 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 PHP is_dir()
is
used.is_link()
and readlink()
.Any ideas?
Ah saw your comment on changing them to 777
but 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
User _www
Group _www
Here is an example of my directory listing.
ace:remote-app ace (git::master)$ ls -al
total 72
drwxr-xr-x 24 ace staff 816 7 Aug 00:24 .
drwxr-xr-x 11 ace staff 374 4 Aug 13:46 ..
drwxr-xr-x 3 ace staff 102 12 Jul 17:06 .bundle
drwxr-xr-x 14 ace staff 476 7 Aug 02:29 .git
-rw-r--r-- 1 ace staff 100 1 Aug 19:20 .gitignore
-rw-r--r-- 1 ace staff 9 1 Aug 19:20 .rspec
drwxrwxr-x 10 ace staff 340 14 Jul 15:58 public
Now my public directory has 775
permissions, meaning owner
and group
have full permissions while other users can only read and execute.
It depends if you want apache user to become ace
from the default _www
or the apache group to become staff
from the default _www
.
Once you've decided on which to change, restart apache.
/usr/sbin/apachectl graceful
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:_www
ownership and you won't have access to them after the restart.
You can change their new ownership through this, -R
is to make it recursive.
sudo chown -R newapacheuser:newapachegroup <path>