I'm having a problem with file permissions within my PHP document when
running on an Apache web server.

When accessing a perl script or an executable from the cgi-bin directory the
web server runs the script as the correct user and group id.  However then a
PHP document is accessed within the same directories as any of my other HTML
documents the web server runs the PHP document as the user "nobody".  I
found this out by calling the PHP function posix_getuid() within this PHP
document.  The problem is that the data files that are own by my account are
not accessible to my PHP document since PHP is running as user "nobody".  I'
m aware that the Apache web server runs as user "nobody" then switches to
the owner of the cgi-bin directory when executing a script, so how do I get
the web server to switch to user "myaccount" when executing a PHP document
from the root directory of the web account including its subdirectories?

The following is my PHP test documents:
On this server user id 99 is "nobody".

=====================================
File test.php
=====================================
<html>
    <head>
        <title>PHP Test</title>
    </head>
    <body>
<?php
echo PHP_VERSION;
echo "<br>";

$uid = posix_getuid();
$gid = posix_getgid();

echo "UID=$uid GID=$gid <br>";

echo "Opening for read index.html<br>";
$file = fopen ("index.html", "r");
if($file != 0) fclose($file);

echo "Opening for write new.html<br>";
$file = fopen ("new.html", "w");
if($file != 0) fclose($file);
?>
    </body>
</html>


=====================================
Output from the web browser
=====================================
4.0.6
UID=99 GID=99
Opening for read index.html
Opening for write new.html

Warning: fopen("new.html","w") - Permission denied in
/www/myaccount/test.php on line 20




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to