Re: Problem with file permissions within my PHP document when running on an Apache web server
| From: | Richard Lynch | Date: | Wed, 03 Oct 2001 02:42:13 +0000 |
| Subject: | Re: Problem with file permissions within my PHP document when running on an Apache web server | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-69676@lists.php.net to get a copy of this message | ||
You'll need to use suExec to wrap around PHP.
http://apache.org will have docs on suexec.
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
----- Original Message -----
From: Jack A. <ja00744@alltel.net>
Newsgroups: php.general
To: <php-general@lists.php.net>
Sent: Tuesday, September 25, 2001 10:14 PM
Subject: Problem with file permissions within my PHP document when running
on an Apache web server
> 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
>
>
>