I have php code on Codeanywhere where I'm simply trying to create a file on the server but yet gets the following error :
"Warning: fopen(file.txt): failed to open stream: Permission denied in /home/cabox/workspace/index.php on line 312"
I use fopen ($file, 'w'). with 'r' as parameter, it works.
I asked CodeAnywhere if there were any restictions coming from them to prevent users from having code able to create files directly on the server but was answered that there were no restrictions and only had to look up how to grant permissions.
First Used chmod for both files and directories
chmod 755 index.php (afterwards 777 for experimental purposes)
Yet I'm still confronted with the error message shown above. So I dug into the permissions at each level of the server and displayed them below but I do not see anything strange (according to my meager knowledge)
/
[cabox@box-codeanywhere /]$ ls -ld
drwxr-xr-x 21 root root 4096 Apr 19 03:09
/home/
[cabox@box-codeanywhere home]$ ls -ld
drwxr-xr-x 3 root root 4096 Jun 16 2014
/home/cabox/
[cabox@box-codeanywhere ~]$ ls -ld
drwxrwxrwx 7 cabox cabox 4096 Apr 14 11:48
/home/cabox/workspace/
[cabox@box-codeanywhere workspace]$ ls -ld
drwxrwxrwx 4 cabox cabox 4096 Apr 19 04:27
I am not able to change the permissions for / as the user name is root I imagine that is because my user name is cabox
[cabox@box-codeanywhere workspace]$ id
uid=500(cabox) gid=500(cabox) groups=500(cabox)
index.php trying to create file.txt is located in /home/cabox/workspace/
-rwxrwxrwx 1 cabox cabox 18608 Apr 19 05:12 index.php
what am i doing wrong?
Thanks in advance!