Permission denied despite appropriate permissions using PHP
Your directory needs execute
permission for this to work. It does not seem to have world execute, and since jenkins
is probably not the apache user, and the apache user is not in the adm
group, it wouldn't work:
$ ls -lh /var/lib/ | grep jenkinsdrwxr-xr-- 6 jenkins adm 4.0K 2011-08-04 10:04 jenkins
Per example:
netcoder@netcoder:~$ mkdir foonetcoder@netcoder:~$ echo hello > foo/barnetcoder@netcoder:~$ chmod 777 foo/barnetcoder@netcoder:~$ ls -lsah foo/bar 4.0K -rwxrwxrwx 1 netcoder netcoder 6 2011-08-04 08:22 foo/barnetcoder@netcoder:~$ chmod 444 foo/netcoder@netcoder:~$ ls -lsah | grep foo4.0K dr--r--r-- 2 netcoder netcoder 4.0K 2011-08-04 08:22 foonetcoder@netcoder:~$ cat foo/bar cat: foo/bar: Permission denied
Even though foo/bar
has 0777
permission, if the directory does not have the execute permission, reading its contents is denied.
You'll need the permission to be set for both the target directory and the symbolic link.
You need the execute bit set on all directories in the hierarchy up to that file.
chmod o+x /var/lib/jenkins
should do the trick.
(Note: ls -lhd /var/lib/jenkins
is a bit better than ls -lh ...|grep jenkins
)
Lots of modern boxes (digital ocean, rackspace etc) ship with SELinux (Security Enhanced Linux) for RedHat compatible OSs (like CentOS). This throws another wrench into the works which you need to keep in mind. You can have your permissions perfectly set and it will still say permission denied. You need to define a writable context for SELinux:
sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite -R