fopen permissions problem - PHP5 and RHEL4 | | |
Hi there,
I'm using fopen for the first time and I know I'm running into a
permissions problem, but I can't seem to resolve it and any help would
be greatly appreciated.
I'm running PHP5 and Apache on RedHat Enterprise Linux 4.
I've verified (by looking in httpd.conf) that Apache is running as
user "apache" and group "apache". So, that's the user/group that PHP
should be running under, right?
The following line of code in my PHP file which, as I understand,
should open a pointer to a file, and create the file if it doesn't
exist (which it doesn't):
$writeFile = fopen($directory . $filename, "w");
This generates the following error:
Warning: fopen(/home/chroot/exports/webleads_200709261803.csv)
[function.fopen]: failed to open stream: Permission denied in /path/to/
filename.php on line 87
I've tried changing ownership of the /home/chroot/exports/ directory
to have the group be "apache" and then done a chmod 775 on the
directory. Still get the error.
In fact, if I chmod 777 on the directory, thus giving every user
permission to write to the dir, I still get the error. I totally
don't understand that...
Any help would be greatly appreciated. I'm really at my wits end at
this point.
Thanks,
Evan | | | | re: fopen permissions problem - PHP5 and RHEL4
IamtheEvster wrote: Quote:
Hi there,
>
I'm using fopen for the first time and I know I'm running into a
permissions problem, but I can't seem to resolve it and any help would
be greatly appreciated.
>
I'm running PHP5 and Apache on RedHat Enterprise Linux 4.
>
I've verified (by looking in httpd.conf) that Apache is running as
user "apache" and group "apache". So, that's the user/group that PHP
should be running under, right?
>
The following line of code in my PHP file which, as I understand,
should open a pointer to a file, and create the file if it doesn't
exist (which it doesn't):
$writeFile = fopen($directory . $filename, "w");
>
This generates the following error:
Warning: fopen(/home/chroot/exports/webleads_200709261803.csv)
[function.fopen]: failed to open stream: Permission denied in /path/to/
filename.php on line 87
>
I've tried changing ownership of the /home/chroot/exports/ directory
to have the group be "apache" and then done a chmod 775 on the
directory. Still get the error.
>
In fact, if I chmod 777 on the directory, thus giving every user
permission to write to the dir, I still get the error. I totally
don't understand that...
>
Any help would be greatly appreciated. I'm really at my wits end at
this point.
>
Thanks,
>
Evan
>
well it seems weird.
Try (as root) going
# su apache
$ touch "pathtofilename"
and see if that works.
If it does, I suspect PHP itself has some permssion stuff getting in the
way. There I can't help.. | | | | re: fopen permissions problem - PHP5 and RHEL4
On Sep 26, 6:43 pm, The Natural Philosopher <a...@b.cwrote: Quote:
IamtheEvster wrote: > Quote:
I'm using fopen for the first time and I know I'm running into a
permissions problem, but I can't seem to resolve it and any help would
be greatly appreciated.
> Quote:
I'm running PHP5 and Apache on RedHat Enterprise Linux 4.
> Quote:
I've verified (by looking in httpd.conf) that Apache is running as
user "apache" and group "apache". So, that's the user/group that PHP
should be running under, right?
> Quote:
The following line of code in my PHP file which, as I understand,
should open a pointer to a file, and create the file if it doesn't
exist (which it doesn't):
$writeFile = fopen($directory . $filename, "w");
> Quote:
This generates the following error:
Warning: fopen(/home/chroot/exports/webleads_200709261803.csv)
[function.fopen]: failed to open stream: Permission denied in /path/to/
filename.php on line 87
> Quote:
I've tried changing ownership of the /home/chroot/exports/ directory
to have the group be "apache" and then done a chmod 775 on the
directory. Still get the error.
> Quote:
In fact, if I chmod 777 on the directory, thus giving every user
permission to write to the dir, I still get the error. I totally
don't understand that...
> Quote:
Any help would be greatly appreciated. I'm really at my wits end at
this point.
> > >
well it seems weird.
>
Try (as root) going
# su apache
$ touch "pathtofilename"
and see if that works.
>
If it does, I suspect PHP itself has some permssion stuff getting in the
way. There I can't help..
Well, If I try to su apache, then I get "The account is currently not
available."
I believe, though, that that's because it's set to be an account that
can't log in. In /etc/passwd, the home directory for the apache
account is /sbin/nologin. If I change that to an actual directory
(one that apache does not have permission to, for example) then I
get:
# su apache
su: /home/otheruser: Permission denied
Even if I try to assign permissions to all or to the apache user, I
get the permission denied error, so not sure what's going on there.
Where in PHP might there be some other permission-related items? Are
there any settings in php.ini I should be looking at?
Thanks again for the help.
Evan | | | | re: fopen permissions problem - PHP5 and RHEL4
IamtheEvster wrote: Quote:
On Sep 26, 6:43 pm, The Natural Philosopher <a...@b.cwrote: Quote:
>IamtheEvster wrote: Quote:
>>Hi there,
>>I'm using fopen for the first time and I know I'm running into a
>>permissions problem, but I can't seem to resolve it and any help would
>>be greatly appreciated.
>>I'm running PHP5 and Apache on RedHat Enterprise Linux 4.
>>I've verified (by looking in httpd.conf) that Apache is running as
>>user "apache" and group "apache". So, that's the user/group that PHP
>>should be running under, right?
>>The following line of code in my PHP file which, as I understand,
>>should open a pointer to a file, and create the file if it doesn't
>>exist (which it doesn't):
>>$writeFile = fopen($directory . $filename, "w");
>>This generates the following error:
>>Warning: fopen(/home/chroot/exports/webleads_200709261803.csv)
>>[function.fopen]: failed to open stream: Permission denied in /path/to/
>>filename.php on line 87
>>I've tried changing ownership of the /home/chroot/exports/ directory
>>to have the group be "apache" and then done a chmod 775 on the
>>directory. Still get the error.
>>In fact, if I chmod 777 on the directory, thus giving every user
>>permission to write to the dir, I still get the error. I totally
>>don't understand that...
>>Any help would be greatly appreciated. I'm really at my wits end at
>>this point.
>>Thanks,
>>Evan
>well it seems weird.
>>
>Try (as root) going
># su apache
>$ touch "pathtofilename"
> and see if that works.
>>
>If it does, I suspect PHP itself has some permssion stuff getting in the
>way. There I can't help..
>
Well, If I try to su apache, then I get "The account is currently not
available."
>
I believe, though, that that's because it's set to be an account that
can't log in. In /etc/passwd, the home directory for the apache
account is /sbin/nologin. If I change that to an actual directory
(one that apache does not have permission to, for example) then I
get:
>
# su apache
su: /home/otheruser: Permission denied
>
Even if I try to assign permissions to all or to the apache user, I
get the permission denied error, so not sure what's going on there.
>
>
Where in PHP might there be some other permission-related items? Are
there any settings in php.ini I should be looking at?
>
Thanks again for the help.
>
Evan
>
Nope, nothing which would cause this problem. open_basedir will limit
directories you can access, but that wouldn't give you this problem.
I'd suggest you try a Linux admin group - figure out what your
permission problems are.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
================== |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,419 network members.
|