RE: [PHP] Problem with PHP and mounted folder

From: Date: Fri, 28 Feb 2014 20:43:14 +0000
Subject: RE: [PHP] Problem with PHP and mounted folder
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-323009@lists.php.net to get a copy of this message
From: Aziz Saleh [mailto:azizsaleh@gmail.com] Sent: Friday, February 28, 2014 1:41 PM To: Cliff Nieuwenhuis Cc: php-general@lists.php.net Subject: Re: [PHP] Problem with PHP and mounted folder r On Fri, Feb 28, 2014 at 1:00 PM, Cliff Nieuwenhuis <c.nieuwenhuis@adcidesign.com> wrote: Cliff Nieuwenhuis wrote: [snip] > The web application needs to read and create files in the projects folder, but > PHP doesn't recognize the projects folder as folder!  I suspect a > permissions problem of some sort, but I can't figure out where.    [snip] Aziz Saleh wrote: > You guessed right. PHP usually runs under a user with less permissions (www, user, etc..). You > are probably > logged in as a user with permissions to access that mounted drive while PHP isn't. Both > fixes are ugly, but > what I would recommend is giving permission to those files as opposed to giving PHP user more > power. Thanks for the reply. I thought that PHP runs under HTTPD as user 'apache'.  I know that the Apache webserver runs as user 'apache' on my system -- does PHP run as a different user?  Assuming that it does not, wouldn't my successful test of traversing, reading, and writing files under the 'projects' folder by doing 'su - apache -s/bin/bash' mean that the permissions are OK?  I guess not, but I can't see why not. -- Cliff Nieuwenhuis You are correct, when I said PHP I meant through the server. Try using runuser command instead. If you have exec enabled, try running an ls command as a user with higher permissions and see if that works. OK -- tried with runuser. I can see all the projects in the projects folder, and I can edit files that I should be able to edit (those files that can be edited by the Windows user account given in the credentials file that is used by mount.cifs). But I can't descend into the projects folder via PHP. If I browse to http://myserver/projects I see Apache's listing of all the subfolders and files. If I click on a test text (test.txt) file in that list, I see the text file contents in the browser. If I write php code like this: $contents = file_get_contents('projects/test.txt'); echo "Contents: $contents"; .it works; the contents are displayed. BUT is_file('projects/test.txt') will return FALSE.

« previous php.general (#323009) next »