Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This is driving me crazy. Really crazy.

Quick story. I've created a symlink:

sudo ln -s /home/richardmandx/Dropbox/www /var/

When i go to localhost (installed via sudo task-sel lamp-server)

You don't have permission to access / on this server.

The problem is, that i've been trying since like 2-3 hours getting this to work and i've changed permissions so i have a real mess now.

Things i want to acomplish:

1) Need to fix permissions again for /home/richardmandx and /home/richardmandx/Dropbox/www

2) I don't know if the symlink /var/www inherits the permissions, if not, i think they need to be fixed.

3) Get rid of 403 error by configuring whatever it needs to be done.

I'd swear this was an easy task ubuntu 8-9 but in ubuntu 11-12 it's getting hard for me to get it.

If this helps, when i run ls -la in my /home/richardmandx i have this (trunked):

drwxr-xr-x  5 root         root          4096 ago 17 20:52 ..
-rw-------  1 richardmandx richardmandx  2344 ago 17 22:37 .bash_history
-rw-r--r--  1 richardmandx richardmandx   220 ago 17 14:59 .bash_logout
drwx------  6 richardmandx richardmandx  4096 ago 17 19:52 .cache
drwxr-xr-x 14 richardmandx richardmandx  4096 ago 17 20:03 .config
drwx------  3 richardmandx richardmandx  4096 ago 17 15:23 .dbus
drwxr-xr-x  2 richardmandx richardmandx  4096 ago 17 20:33 Descargas
-rw-------  1 richardmandx richardmandx    28 ago 17 22:40 .dmrc
drwxr-xr-x  2 richardmandx richardmandx  4096 ago 17 15:23 Documentos
drwx------  3 richardmandx richardmandx  4096 ago 17 23:00 .dropbox
drwx------  4 richardmandx richardmandx  4096 ago 17 22:40 Dropbox
drwxr-xr-x  3 richardmandx richardmandx  4096 ago 17 20:31 .dropbox-dist
drwxr-xr-x  2 richardmandx richardmandx  4096 ago 17 15:23 Desktop

Inside /home/richarmandx/Dropbox/www looks like this:

drwxr-xr-x  6 www-data     www-data       4096 ago 17 20:56 pyrocms
drwxr-xr-x  5 www-data     www-data       4096 ago 17 20:58 ricvega
drwxr-xr-x  6 www-data     www-data       4096 ago 17 20:58 ser-website
drwxr-xr-x  3 www-data     www-data       4096 ago 17 20:37 slate
drwxr-xr-x  9 www-data     www-data       4096 ago 17 21:13 sofom
drwxr-xr-x  6 www-data     www-data       4096 ago 17 20:59 tzz
drwxr-xr-x 11 www-data     www-data       4096 ago 17 20:58 vanilla

And finally, my symlink /var/www looks like this:

drwxr-xr-x  6 www-data     www-data       4096 ago 17 20:56 pyrocms
drwxr-xr-x  5 www-data     www-data       4096 ago 17 20:58 ricvega
drwxr-xr-x  6 www-data     www-data       4096 ago 17 20:58 ser-website
drwxr-xr-x  3 www-data     www-data       4096 ago 17 20:37 slate
drwxr-xr-x  9 www-data     www-data       4096 ago 17 21:13 sofom
drwxr-xr-x  6 www-data     www-data       4096 ago 17 20:59 tzz
drwxr-xr-x 11 www-data     www-data       4096 ago 17 20:58 vanilla

Can some good soul can help me fixing this?

Thank you in advance!!!

share|improve this question
    
755 would be correct i think.. –  karthick87 Aug 18 '12 at 4:19
add comment

1 Answer 1

up vote 1 down vote accepted

My understanding of how www-data fits in is that none of the files or directories are owned by that user. It is the user that Apache runs as, and the whole point is that www-user has reduced privileges, and doesn't own the files or have permissions to change them.

The actual owner should be either you or root, I believe, so www-data will then have read-only privileges, not rwx.

Did you create a link in /var to /home/richardmandx/Dropbox/www? I don't understand why you'd do that. What I do for my personal test server is to simply create the virtual server in ~/www, by editing /etc/apache2/sites-enabled/000-default, and either change /var/www to /home/me/www, or add more virtual servers in whatever directories I want to use.

Edits:

If this is a home server without general outside access, I think it's easiest for developing to change the local server from /var/www (owned by root) to your home directory/www, or something similar. You could probably just as well change the owner of /var/www from root to yourself, giving r-- permissions for group/others. This is the normal permissions when root is owner.

Making yourself the owner makes it much easier to edit files, as you won't need to copy back and forth, or use sudo. Another option is to mount /var/www in a directory you own, but you might need to give extra options for the permissions. This is probably easier than it might sound.

If you do have outside access, you would probably do best to leave things as they are normally set up. I have a clean, default server on a test 12.04 VM, set up using the standard install, which works fine. /var/www is owned by root, with permissions 'drwxr-xr-xfor the directory, and-rw-r---r--` for the files. There is no www-data shown anywhere, as it should be, if my understanding is correct. You don't want outsiders to have to many permissions, so www-data is a limited user for Apache that meets that requirement. It has less authority than you do.

If you want to use your home directory, then the simplest, cleanest way is to edit /etc/apache2/sites-enabled/000-default, and change all (or at least the innermost) occurrences of /var/www to whatever directory you choose, and then restart Apache. You can add any number of virtual web sites to the inner part of configuration, similar to this one, with any name you want and a matching directory. I create sites with a name like "mysite.dev", and on any machine that accesses it, I make an entry in /etc/hosts with something like 192.168.1.111 mysite.dev. Apache will then take that name, look it up to get the directory for the virtual site, and open it.

share|improve this answer
    
Hello Marty, thanks for your reply. I created the symlink becase people say that it's easier to keep everything in home/user/www for example and link it to /var/www than moving everything inside /var/www. I've done in the past as you suggest but that does not work for me in ubuntu's latest version. I remember seeing a tutorial where it was explained how to give proper permissions to www-data, i hate myself for not bookmarking it. –  Richard-MX Aug 18 '12 at 6:41
    
I added more to my reply as it was too long for a comment. Hope it might help. My advice is to be careful about tutorials, and double check if not from a known reliable source because there's a lot of misinformation, and I don't think changing permissions for www-data is a good strategy. But double-check my info, too (or wait to see if it gets contradicted). I will say I've set up servers both personally and professionally, and they all work fine. –  Marty Fried Aug 18 '12 at 16:28
1  
Thank you Marty, i just wanted to set up a home development environment. I'll tried as you said in your last paragraph and it works like a charm. Thanks again :) –  Richard-MX Aug 24 '12 at 18:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.