Jump to content

Recommended Posts

Posted

Hi,

I have php script for creating files. It actually opens a file for writing and then copies the content for a template then the new file is chmod(ed) to 777. Now the main problem is with the permission. I need to set the permission of the folders as well of the files to 777 which makes it vulnerable. I was told by the server people to change the permission to 755 but doing so, the script doesnt work.

 

chown -R <username>:apache <directoryname>

chmod g+s <directoryname>

 

I asked my server administrator to execute the above commands, which he did but still the scripts are not executing. Its showing the error "fopen(test.php): failed to open stream: Permission denied" error(while trying to create the file test.php)

 

The whole thing is, to get the script execute without giving the folders a 777 permission. How should I go about for this.This is urgent and any help from you will be highly appreciated.

Posted

Welcome to the forums shik.

 

Changing the directory owner to "apache" won't solve it but changing it to "nobody" may as that is the user that apache runs under.

Posted

Hi and thank you for your warm welcome. Okay, talking about my problem again, my script needs to do these things ... it needs to create a file and that file needs to be writable. So both the file as well as the directory in which it is written should be writable. Right now like I said before for the directories I am giving 777 permission and once the file is created its chmod(ed) to 777(via the script). Now I need to keep permission of both these to 755 (as my server administrator suggested) but still get the script running. I am very vague about this and would be highly obliged if anyone could let me know how I should go about.

 

shik

Posted

Hi,

Okay I had previously posted regarding the permission of the folders. Just to brief it up. I have a script to create files in php. Now the folder where the files are created has the permission set to 755 but as suggested by some forum users I asked my server admin to change the folder ownership to nobody. However I am still getting the problem with the permission, that is, I cant upload the files via FTP and the script isnt running as well. I am totally confused so can anyone help me out? This is what I want to do ... create files via PHP script but without giving 777 permission to the folder where the file is created.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...