Re: is_dir true from cli, false from Apache



On 5/23/2012 3:17 PM, Robert Heller wrote:
At Wed, 23 May 2012 14:04:37 -0400 Jerry Stuckle<jstucklex@xxxxxxxxxxxxx> wrote:


On 5/23/2012 1:24 PM, Robert Grimm wrote:
On 2012-05-23 17:10:31 +0000, Jerry Stuckle said:

On 5/23/2012 12:45 PM, Robert Grimm wrote:
I'm having trouble on CentOS 6 with PHP5. This is my test code:

$dir = is_dir("/var/www/document_repository");

Ultimately, I'm trying to get OpenDocMan working. That this test code
fails shows why I can't get OpenDocMan working. I've tried everything I
can think of. I've added a trailing /. I've put the directory in and out
of the OpenDocMan directory, which has a directory definition in the
Apache config. The user apache owns and has full access to the
directory. I tested to make sure PHP was being run by apache with
passthru("whoami");

I posted my site configuration and phpinfo() output at
http://opendocman.com/forum/viewtopic.php?f=4&t=667 in the last post on
the page as of right now.

What is really strange is that my test code works when I run it from the
command line.

This is a recent, clean install of CentOS. I have done no customization
of the configuration files beyond defining the site in Apache. The site
configuration has no PHP directives, as can be seen in the forum post
linked above. What is going on? What do I have to do to get this
working?


Does the web server's user have access to the directory?

The web server's user has ownership and read, write, and execute
permissions on that directory.

OK, but IIRC, CentOS uses SELinux security contexts. Is that set up to
allow access to the directory (warning - I know very little about how
SELinux security works - just that it causes hassles like this).

There is also the possiblity that the apache (most likely) and/or php
configuration might prevent a php web application from accessing disk
space outside of under DOCUMENT_ROOT. The base default DocumentRoot
for a CentOS install of apache (httpd rpm) is /var/www/html and
/var/www/document_repository is outside of that directory... I am not
sure if this is an apache or php configuration. I *suspect* that the
default is to disallow a php program running under apache's PHP_MOD
from accessing files, unless apache is allowing it. By default apache
disallows access to the root file system (from httpd.conf):


When accessing the file system from PHP, Apache is not involved at all, and its configuration is immaterial.

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

(This directive is followed by others granting various sorts of access
to selected directories.)

This is a sensible securirty setting. You might have to add the
necessary 'magic' to httpd.conf or add a config file to
/etc/httpd/conf.d to allow access to /var/www/document_repository, with
a suitable<Directory /var/www/document_repository>...</Directory>
container.




And unrelated to this problem. Actually, since the directory is outside of the DOCUMENT_ROOT, this isn't even necessary (and has no effect).


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Help with php5 install under windows
    ... This includes moving php from the ... Enable the PHP scripting language engine under Apache. ... or per-virtualhost web server configuration file. ... The PHP directives register_globals, ...
    (php.general)
  • Re: is_dir true from cli, false from Apache
    ... I'm trying to get OpenDocMan working. ... The user apache owns and has full access to the ... of the configuration files beyond defining the site in Apache. ... configuration has no PHP directives, as can be seen in the forum post ...
    (comp.lang.php)
  • Re: is_dir true from cli, false from Apache
    ... I'm trying to get OpenDocMan working. ... The user apache owns and has full access to the ... There is also the possiblity that the apache and/or php ... sure if this is an apache or php configuration. ...
    (comp.lang.php)
  • Re: Forms and PHP V5.0.2 with APACHE V2.0.50
    ... Not relevant to the current issue, but MySQL 4.1 went General Availability ... To use my HOME PC to run a local APACHE web server on which to ... >develop websites that make use of PHP scripts and MySQL databases. ... PHP only reads its configuration on startup. ...
    (comp.lang.php)
  • Re: is_dir true from cli, false from Apache
    ... I'm trying to get OpenDocMan working. ... The user apache owns and has full access to the ... of the configuration files beyond defining the site in Apache. ... configuration has no PHP directives, as can be seen in the forum post ...
    (comp.lang.php)