shik Posted July 5, 2006 Posted July 5, 2006 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. Quote
TCH-JimE Posted July 5, 2006 Posted July 5, 2006 Hello and welcome to the forums, Try changing the permission first to 777, then doing what you need, and then CHMOD it back again when finished. JimE Quote
TCH-Bruce Posted July 5, 2006 Posted July 5, 2006 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. Quote
shik Posted July 6, 2006 Author Posted July 6, 2006 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 Quote
shik Posted July 6, 2006 Author Posted July 6, 2006 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. Quote
TCH-Bruce Posted July 6, 2006 Posted July 6, 2006 I've merged the topics as they are the same. Please do not start new duplicate threads to get your questions answered. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.