Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here is my problem. Sorry if the subject was discussed before, but I didn't find it. Also, sorry if the place for my question is not here.

I have a website on a server using Apache 2.04 and PHP 5. During website navigation, a script creates a .xml file with 755 rights and apache:apache owner. The problem is that this file created is not accessible from a .swf file neither from a different browser window - trying to access it directly by typing it's absolute path.

I discovered that changing owner to root:root, the .xml file became accessible in both situations. Trying to change owner or rights using PHP function, no changing happened.

Please help me and tell me what can I do in order to fix this problem. It is a PHP configuration?

Thank you in advance.

share|improve this question
    
+1 for pointing out a common programming pitfall. it should be fixed by programmers, not by server admins. :) –  risyasin Jun 25 '10 at 16:49
add comment

3 Answers

up vote 0 down vote accepted

it's not a php configuration problem or apache problem. just a programming pitfall.

While uploading or creating new files with PHP, it always will use default "umask". if you did not provide correct umask or CHMOD of file, it may not be accessable by other applications even apache. (because it's made by your code)

here is link for umask & chmod.
http://php.net/manual/en/function.umask.php
http://www.php.net/manual/en/function.chmod.php

Try to solve the problem with php code. like: just after you upload or create new file, change chmod of file.

chmod("/somedir/somefile", 0644); 

this way is better, efficent, compatible.

share|improve this answer
    
Thank you very much Yasin. You're great! –  Horace Jun 25 '10 at 15:22
add comment

Maybe a directory in the full path of xml file is not readable by apache user.

Check permissions of every directory of xml path file, you can try to read directory content:

sudo -u apache ls -l /GRAPHICS/

sudo -u apache ls -l /GRAPHICS/video/

sudo -u apache ls -l /GRAPHICS/video/files/

Maybe you should add apache user to the proper group, but it depens by you user rights on this directory.

share|improve this answer
    
Thank you for your fast answer. I think so, but how can I fix it? Where to looking for? Apache settings? –  Horace Jun 25 '10 at 8:23
    
I edited my answer –  lg. Jun 25 '10 at 10:05
    
For sure you are right about the apache rights. This is my problem! Where to set the rights? In a .htaccess file placed in folder it is ok? –  Horace Jun 25 '10 at 15:32
add comment

It's possible you're server permissions require 644 for PHP scripts, assuming it gives an Internal Server Error

share|improve this answer
    
Here the error: You don't have permission to access /GRAPHICS/video/files/video_ro_biz02.xml on this server. Rather is a problem of owner:group access. –  Horace Jun 25 '10 at 8:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.