# PHP Won't Access Files Outside WebServer !!



## mickey79 (Nov 1, 2007)

Ave,

Somehow my PHP won't access, won't even acknowledge the existence of a file that is *outside the /Library/WebServer/Documents* folder. This was never a a problem before in any Mac version - it just started with Leopard. 

I don't know what has changed where, in httpd.conf or php.ini or somewhere else, but something changed that's crippling access to files outside of the webserver.

*This Works in Mac OS X 10.3.9* (i.e., prints File Exists) but the same exact script* does not work in Mac OS X 10.5*, and yes, the file is available in Leopard in the mentioned location - path is exact same - permissions are all set:

$filename = "/Users/username/Documents/Transfers/test.txt";
if (file_exists($filename)) {
    echo "The file $filename exists<br><br>";
} else {
    echo "The file $filename does not exist<br><br>";
}

Any ideas what might be causing this?

Thanks!


----------



## macbri (Nov 1, 2007)

mickey79 said:


> path is exact same - permissions are all set



And these permissions are?  And what are the permissions of each parent directory?


----------



## lurk (Nov 1, 2007)

I am talking _ex recto_ because I have not looked into the specifically but I believe that in Leopard servers like httpd are run from inside a sand box that hides the rest of the system from them as a security measure.  It is a parallel of BSD Jails if I remember right.

I'll check later on today and see if I can find more specific info on this.


----------



## mickey79 (Nov 1, 2007)

*@ macbri*,

The folder in which the files reside which I'm trying to access via PHP, "osm", is a Share Point which has a windows network share mounted on it (via SMB).

I'm not sure where the problems are in permissions, because while mounting,
I'm allowing full read/write permissions to share:
Mount_smbfs -f 777 -d 777 //userwd@ip/share sharePoint

Not sure if there is something else I can do to give it any different permissions.

*@ lurk*,

If permissions aren't my issue, then you might be on to something!


----------



## elander (Nov 1, 2007)

Permissions are not to blame here, it's the Installer that malfunctioned.

Your problem is that the Leopard installer didn't move the /etc/httpd/users/ to /etc/apache2/users/. It had me stumped too, but once i manually moved them everything worked fine, and still does.

PS: you're no longer running Apache 1, in Leopard it's Apache 2...


----------



## mickey79 (Nov 1, 2007)

elander said:


> Permissions are not to blame here, it's the Installer that malfunctioned.
> 
> Your problem is that the Leopard installer didn't move the /etc/httpd/users/ to /etc/apache2/users/. It had me stumped too, but once i manually moved them everything worked fine, and still does.
> 
> PS: you're no longer running Apache 1, in Leopard it's Apache 2...



I'm not quite sure what you're getting at. 
I had a clean (erase & install) installation of Leopard. I do have etc/apache2/users which has a 'myusr.conf' with the following:
<Directory "/Users/myusr/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

But I don't know what this has to do with my problem. I use VirtualHosts and I have my websites in /Library/WebServer/Documents. Everything is working fine except for PHP not being able to read/access files which are outside of /Library/WebServer/Documents or on a Share Point.


----------



## mickey79 (Nov 1, 2007)

Here's another way of explaining my problem. 
In Panther, I was able to specify Apache Web Server to be the User/Group for the share being mounted with -u 70 -g 70 during mount_smbfs. 

In Leopard I'm not able to do that because they eliminated the -u -g arguments for mount_smbfs - in fact they even eliminated NetInfo Manager so I don't even know Apache's UID & GID. 

So after mounting the share on the share point, this is what happens:







As you can see files within the mounted share had "www" (Apache) as the user & group and PHP didn't have any problems accessing the files. But in Leopard, "www" (Apache) is not the user/group - which I think is the problem.


----------

