Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please, How Configure Apache to fopen() can write...

Status
Not open for further replies.

ejgarcia

IS-IT--Management
May 28, 2003
72
US
Hello all,

Please How Configure Apache to fopen() can write...

the message I'm getting in my php script is the following:

Warning: fopen(count.txt): failed to open stream: Permission denied in /home/egarc1a/public_html/webex/alistar.php on line 33

Thanks you
 
Apache runs as a user on the system. When Apache runs a program, that program runs as Apache's user.

Apache's user must have permission to write to the file. If the program is creating the file, Apache's user must have permission to write to the directory.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
ejgarcia,

It looks like you just need to chmod 666 count.txt. If this is just a file that is read and incremented each page load, I have one just like it on my site.

Let me know if this works.



Wishdiak
 
Hello Wishdiak,

Thanks you very much, it works...

Regards.
 
Hello sleipnir214,

Thanks you very much you too, for your suggestions...

Regards.
 
Thanks.

But remember that although allowing world write to a file will work around your problem, allowing world write is, in general, contraindicated. As a matter of policy, you should not give world write permission to anything.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
sleipnir214,

That's a good point that you make.

One could just chown the file and make it readable by the user/group assigned to apache instead. In this case, it's a counter, so overwriting it is not a security issue (IMHO).



Wishdiak
 
You're right -- this specific case, granting world write to the file is probably no big deal. But it is an extraordinarily bad habit go get into.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Hello,

Great point, but how can I do to configure this file for security?

Thanks you,

Regards.
 
Again, figure out as which user and group Apache is running. Change ownership and permissions on the file such that that user or group has write permission to the file.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Hello,

Ok. I will perform this suggestion!!

Thanks to all!!

Regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top