Web Hosting Talk







View Full Version : Unable to create a file php/permissions etc..


nogi
01-19-2004, 07:26 PM
Before a server crash php scripts would access (read/write) files as the user/owner of an account. Now, when a client creates a file with php the User/Group for the created file is nobody(99)/99 (also, the directory has to have chmod 777 set which is a bad policy). An account uses a php script which is unable to create a file "/home/username/public_html/testCGI/test.txt" because permission is denied, because the apache user/group is nobody/nobody (99/99). We can chmod 777 the directory and the script will work, but that has bad security implications, leaving the directory wide open for anyone on the server to read/write to the files, and we would like to be able to have chmod 775 or 755 permissions.

Phpsuexes in enabled on this server. I thought that this should take care of it, as permissions higher than 755 shouldn't be necessary. Does anybody here know how to handle this problem?

Thanks
John

blessen
01-19-2004, 10:19 PM
You are not able to create file with php script because..your php scrip is executed as nonbody (apaches user)..so this user will not have permission to create file in your home directory..
soltuion is
1)give permission to your home directory so that nobody can create files

2)enable phpsuexec..

My vote will go for phpsuexec.This will make sure that php scripts are executed as user which owns the script

choon
01-20-2004, 12:16 AM
nogi, what is the ownership of those php files and directories need to be written by those php files? Try to chown all php files to be owned by your account user and the directory to be written also then set the permission accordingly.

blessen, nogi already enabled phpsuexec.

blessen
01-20-2004, 02:11 AM
if phpsuexec is enabled and still this error then please do the following
1)login to the server as root
2) vi httpd.conf
3) locate your domains virtualhost entry and check if there is an entry like this

User <username>
Group <groupname >

nogi
01-20-2004, 05:37 AM
Hello Blessen,

Yes I see this in httpd.conf:

User Spk65
Group Spk65

maybe phpsuexec isn't installed properly? - In WHM it says, however, that phpsuexec is installed.

John