Raam Dev » thoughts essays journal notes contact about subscribe rss

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:

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#

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 #apache on EFnet. They explained that the directory needs to have the +x (execute) attribute applied in order for Apache to change INTO the directory:

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#

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 #apache 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.

  1. /wow

Leave a Reply

Subscribe without commenting.

Other posts you may enjoy:

Where in the world is Raam?

Join the Facebook Community

Raam Dev » thoughts essays journal notes contact about subscribe rss

Powered by WordPress and other Open Source Software
Uncopyright by Raam Dev