I am trying to grant apache permission to a file in my home folder, so that a php page might write log data to that file. Below find what I have done to accomplish this in my bash
shell, and I cannot figure out why this won't work:
[root@myserver logs]# mkdir apachelogs
[root@myserver logs]# touch apachelogs/log.log
[root@myserver logs]# chown -R apache:apache apachelogs
[root@myserver logs]# chown -R apache:apache apachelogs/log.log
[root@myserver logs]# chmod 770 apachelogs
[root@myserver logs]# su apache
bash-4.1$ cd apachelogs
bash: cd: apachelogs: Permission denied
So I have just granted apache ownership, read, write, execute permission, yet clearly apache still does not have access to the directory, and this is verified when my php script runs this line of code:
echo exec(whoami)."\n";
file_put_contents("/home/chilinut/logs/apachelog/log.log","test",FILE_APPEND);
The output is (not surprisingly)
apache
E_WARNING: file_put_contents(/home/chilinut/logs/apachelog/log.log):
failed to open stream: Permission denied
What am I missing here?
I don't want to give the folder 777. I'd rather it have something like 644. I am using CentOS release 6.4 (Final)
Thanks for reading!