Learn your *nix permissions!

I spent so many hours trying to figure out how to give Apache access to files that were owned by another user. First, I created a symlink to the directory:

[code]
mercury:/var/www# ln -s /home/raam/gallery gallery
mercury:/var/www# ls -al
total 12
drwxr-xr-x 3 root root 4096 2006-06-02 23:28 .
drwxr-xr-x 14 root root 4096 2006-05-14 21:50 ..
lrwxrwxrwx 1 root root 18 2006-06-02 23:20 gallery -> /home/raam/gallery
mercury:/var/www#
[/code]

However, when I tried accessing that directory via HTTP, Apache said permission was denied. I tried adding /home/raam/gallery to the httpd.conf file using the clause, but that did nothing as well.

Finally, as is always my last resort, I asked for help in on EFnet. They explained that the directory needs to have the +x (execute) attribute applied in order for Apache to change INTO the directory:

[code]
raam@mercury:~$ ls -al
total 85620
drwxr-xr-x 16 raam raam 4096 2006-06-02 23:32 .
drwxrwsr-x 5 root staff 4096 2006-06-02 22:13 ..
................
drwx--x--x 4 raam raam 4096 2006-06-02 22:24 gallery
raam@mercury:~$ sudo su
mercury:/home/raam# chmod 755 /home/raam/gallery
mercury:/home/raam# ls -al
total 85620
drwxr-xr-x 16 raam raam 4096 2006-06-02 23:32 .
drwxrwsr-x 5 root staff 4096 2006-06-02 22:13 ..
................
drwxr-xr-x 2 raam raam 4096 2006-06-02 23:48 gallery
mercury:/home/raam#
[/code]

Problem solved! Now I can create the symlink and Apache will be able to access and read all the files in /home/raam/gallery even though all those files are owned by raam and not www-data (the user that Apache runs as).

As the guys in said, if you're going to be using a *nix system (as I am using Linux), learn your permissions! They are a central part of the system, and understanding how they work will save you a lot of headaches; like the one I have right now.

Write a Comment

Comment

  • Related Content by Tag