473,587 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

permission denied - fopen

What can cause the PHP code fopen("filename ","a") to fail with
permission denied message as below?
------------------
Warning: fopen(filename) : failed to open stream: Permission denied in
/home/lookout/u2/kmei/www/test1.php on line 14
------------------
I write a short PHP code that works fine on my own apache server, but it
doesn't work after I upload it to the university server. Note that
'chmod 777 filename' works as expected.

thanks
Jul 17 '05 #1
9 7143
bird <bi**@village.o rg> wrote in news:cv688a$jn$ 1
@mailhub227.itc s.purdue.edu:
What can cause the PHP code fopen("filename ","a") to fail with
permission denied message as below?
------------------
Warning: fopen(filename) : failed to open stream: Permission denied in
/home/lookout/u2/kmei/www/test1.php on line 14
------------------
Hi,

It's a permissions issue one way or another.
I write a short PHP code that works fine on my own apache server, but it doesn't work after I upload it to the university server. Note that
'chmod 777 filename' works as expected.

thanks


This is odd. I am assuming that there is a file named "filename" in
/home/lookout/u2/kmei/www/ and that this is the file you have chmod 777?

hth
--
Bulworth : PHP/MySQL/Unix | Email : str_rot13('f@fu ng.arg');
--------------------------|---------------------------------
<http://www.phplabs.com/> | PHP scripts, webmaster resources
Jul 17 '05 #2
Senator Jay Billington Bulworth wrote:
bird <bi**@village.o rg> wrote in news:cv688a$jn$ 1
@mailhub227.itc s.purdue.edu:

What can cause the PHP code fopen("filename ","a") to fail with
permission denied message as below?
------------------
Warning: fopen(filename) : failed to open stream: Permission denied in
/home/lookout/u2/kmei/www/test1.php on line 14
------------------

Hi,

It's a permissions issue one way or another.

I write a short PHP code that works fine on my own apache server, but


it
doesn't work after I upload it to the university server. Note that
'chmod 777 filename' works as expected.

thanks

This is odd. I am assuming that there is a file named "filename" in
/home/lookout/u2/kmei/www/ and that this is the file you have chmod 777?

hth

Yes, the file I want to write in the PHP code is exactly the file
changed its mode to 777. I wonder if the administrator has some special
way to overrule my file mode.
Jul 17 '05 #3
who owns the folder?

--

"bird" <bi**@village.o rg> wrote in message
news:cv******** **@mailhub227.i tcs.purdue.edu. ..
Senator Jay Billington Bulworth wrote:
bird <bi**@village.o rg> wrote in news:cv688a$jn$ 1
@mailhub227.itc s.purdue.edu:

What can cause the PHP code fopen("filename ","a") to fail with
permission denied message as below?
------------------
Warning: fopen(filename) : failed to open stream: Permission denied in
/home/lookout/u2/kmei/www/test1.php on line 14
------------------

Hi,

It's a permissions issue one way or another.

I write a short PHP code that works fine on my own apache server, but


it
doesn't work after I upload it to the university server. Note that
'chmod 777 filename' works as expected.

thanks

This is odd. I am assuming that there is a file named "filename" in
/home/lookout/u2/kmei/www/ and that this is the file you have chmod 777?

hth

Yes, the file I want to write in the PHP code is exactly the file
changed its mode to 777. I wonder if the administrator has some special
way to overrule my file mode.

Jul 17 '05 #4
bird wrote:
Senator Jay Billington Bulworth wrote:
bird <bi**@village.o rg> wrote in news:cv688a$jn$ 1
@mailhub227.itc s.purdue.edu:

What can cause the PHP code fopen("filename ","a") to fail with
permission denied message as below?
------------------
Warning: fopen(filename) : failed to open stream: Permission denied in
/home/lookout/u2/kmei/www/test1.php on line 14
------------------


Hi,

It's a permissions issue one way or another.

I write a short PHP code that works fine on my own apache server, but

it
doesn't work after I upload it to the university server. Note that
'chmod 777 filename' works as expected.

thanks


This is odd. I am assuming that there is a file named "filename" in
/home/lookout/u2/kmei/www/ and that this is the file you have chmod 777?

hth

Yes, the file I want to write in the PHP code is exactly the file
changed its mode to 777. I wonder if the administrator has some special
way to overrule my file mode.


I think Jeb hit the nail on the head: in order to modify a file, you
need write access to both the file AND the dir that contains it.

--
convert UPPERCASE NUMBER to a numeral to reply
Jul 17 '05 #5
Jeb Hunter wrote:
who owns the folder?

The folder modes is as below:
----------------------------------
drwxrwxrwx 9 kmei student 4096 Feb 18 22:31 www
----------------------------------
The parent of 'www' is my home on the server. please see the path:
/home/lookout/u2/kmei/www/test1.php
'kmei' is my ID on the server.

thanks again.
Jul 17 '05 #6
bird wrote:
Jeb Hunter wrote:
who owns the folder?

The folder modes is as below:
----------------------------------
drwxrwxrwx 9 kmei student 4096 Feb 18 22:31 www
----------------------------------
The parent of 'www' is my home on the server. please see the path:
/home/lookout/u2/kmei/www/test1.php
'kmei' is my ID on the server.

thanks again.

A couple of other details I want to provide here. Maybe there are
helpful for you guys to diagnose.

1) I initially wrote the code with perl. That code worked for more than
one year, but it doesn't work any more since a few weeks ago. I found
the perl code open (handle, "filename") failed for whatever reason.

2) I switched to use PHP to implement to same function a couple of days
ago. Then you know all about it now.

3) If I use command line to execute the perl code,
perl perlcode.pl
the code can correctly write the output file: 'filename'

4) The server doesn't allow me to run the PHP executable from the
command line, so I can provide other details any more.

thanks,
Jul 17 '05 #7
bird wrote:
bird wrote:
Jeb Hunter wrote:
who owns the folder?
The folder modes is as below:
----------------------------------
drwxrwxrwx 9 kmei student 4096 Feb 18 22:31 www
----------------------------------
The parent of 'www' is my home on the server. please see the path:
/home/lookout/u2/kmei/www/test1.php
'kmei' is my ID on the server.

[snip] 3) If I use command line to execute the perl code,
perl perlcode.pl
the code can correctly write the output file: 'filename'


When the webserver (apache..?) executes the script (perl or php), it's
not running as kmei:student, it's probably running as apache:apache or
whatever user:group the server administrator has configured apache to
run as. Whatever user:group apache runs as needs to have read-execute
privilege through all dirs in the path up to www, where it also needs
write privilege; it needs read-write privilege on test1.php.

NM

--
convert UPPERCASE NUMBER to a numeral to reply
Jul 17 '05 #8
News Me wrote:
bird wrote:
bird wrote:
Jeb Hunter wrote:

who owns the folder?

The folder modes is as below:
----------------------------------
drwxrwxrwx 9 kmei student 4096 Feb 18 22:31 www
----------------------------------
The parent of 'www' is my home on the server. please see the path:
/home/lookout/u2/kmei/www/test1.php
'kmei' is my ID on the server.


[snip]
3) If I use command line to execute the perl code,
perl perlcode.pl
the code can correctly write the output file: 'filename'

When the webserver (apache..?) executes the script (perl or php), it's
not running as kmei:student, it's probably running as apache:apache or
whatever user:group the server administrator has configured apache to
run as. Whatever user:group apache runs as needs to have read-execute
privilege through all dirs in the path up to www, where it also needs
write privilege; it needs read-write privilege on test1.php.

NM

Yes, I think I understand your point. I knew it's different to run the
PHP/perl code by a command line or by a web browser. That's why I didn't
mention the above 3) case when I first asked for help. I actually set
the mode of every related file and folder to 777, since I have been
trying hard to find the "bug". By saying that I mean the mode of the two
files 'test1.php' and 'filename' were set to 777, and so was the folder
'www'. Thus, 'all users' including 'apache' and 'nobody' should have the
read-write-execute privilege to all the related files.

I wonder if the administrator has done something special to the system,
or it's a bug in the system, or whatever beyond my knowledge. I am just
curious to learn it. (Note that I've already achieved my goal to
implement the same function by PHP+MySQL on the university server; I
write data to MySQL database instead of a local file.)

Thank you very much,
Kevin
Jul 17 '05 #9
bird wrote:

[big snip]
I wonder if the administrator has done something special to the system,
or it's a bug in the system, or whatever beyond my knowledge. I am just
curious to learn it. (Note that I've already achieved my goal to
implement the same function by PHP+MySQL on the university server; I
write data to MySQL database instead of a local file.)


I doubt it's a bug. As a security measure the admin may have restricted
PHP and/or Apache to only be allowed to write files in a specific
branch of the filesystem.

NM

--
convert UPPERCASE NUMBER to a numeral to reply
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2261
by: Marc | last post by:
Hello, when using flock() I get a permission denied error: Warning: fopen("<filename>", "r+") - Permission denied in <pathtofile> on line 7 I do this: $fileToOpen=substr($PHP_SELF, strrpos($PHP_SELF,"/")+1); $fileHandle=fopen($fileToOpen, 'r+') or die($php_erormsg);
1
4160
by: JaazzMan | last post by:
Hi! I wrote this script and executed on my server, with php 4.1.2 <?php $fp = fopen('test.txt', 'w'); fwrite($fp, "Bla bla"); fclose($fp); ?> it returns this message:
0
2560
by: glesaux | last post by:
Hi, In one of my script i'm trying to apend a daily log file (see script part bellow). When the script runs, this message appears : fopen(temp/pglog.20050106.log): failed to open stream: Permission denied... I've searched in many post and the solution seems to change the permissions (chmod o+777). I did so, but it doesn't change. The...
8
36647
by: Lee C. Haas | last post by:
I have created the file lhcount.data with the content the number 1 in it. This file is in the same directory (public_html) as the following index.php file that contains the following code: <?php echo("count"); $fh = fopen('lhcount.data','r+'); result is:
3
1818
by: fAnSKyer | last post by:
I am trying to make a new file using fopen, but I got a exception: failed to open stream: Permission denied in tmp/ .. I am using linux and I've already chmod the php file to 777. I tried adding exec("touch afile") in my php program and the result is there is no exception but no file come out. I am confused? how to control the...
1
3550
by: doctorhardik | last post by:
other interesting thing i observe during my work which i describe below: i am using dotproject2.0.4 on fc3. it is working fine. but i want to generate pdf file report during this time i face permission denied problem. Warning: fopen(/var/www/html/dotproject/files/temp/temp1.pdf): failed to open stream: Permission denied in...
3
6490
gagandeepgupta16
by: gagandeepgupta16 | last post by:
hi I need urgent help on this please.... i am a newbie in PHP. i am using php on windows and IIS 5.1 i am working on counter module for website... i have a text file that contains the count. what i have to do is read the count value from the file, add 1 and again write back to the file...
2
2477
by: swethak | last post by:
Hi, when i run my code it gives error as fopen(lib/providers//provider.RVLogic.php): failed to open stream: Permission denied in F:\Facebook\furniture11\Data Mining\public_html\lib\inc\functions.lib.php Line 673 : trigger_error("Failed to open stream to $filename. Permission denied!", E_USER_ERROR); could you plz tell the solution...
2
2595
by: gowthamkg | last post by:
Hi All, I Have Installed Wamp Server In My System.....i Have Written A Simple Php Program To Read And Display The Details Inside A File...so I Used Fopen...but The Output Is Permission Denied..why?
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.