1

I've an issue with file ownerships.

I have a drupal website and the "files" folder needs to be owned by "www-data" in order to let the users to upload files with php.

However I'm now using svn and I need all folders and files to be owned by my ubuntu user in order to work.

Files have 775 permissions, so both user and group have full access to the files.

I've added my ubuntu user to www-data group but it still doesn't work. I don't know why. I've tried to change the group to my ubuntu user group but it still doesn't work.

I've also tried to set my ubuntu user as owner, and www-data as group, but in this case the webserver php script cannot anymore upload files into the folder (and this is again strange because the group has full privileges).

1
  • “it doesn't work”… “it” being what? On a hunch: have you checked that all relevant directories are group writable? Jan 5, 2011 at 19:34

1 Answer 1

2

In any sort of web development, there are usually several good reasons to handle development differently from production. It's convenient to have a local copy of your web site in your home directory for development, but accept that it's okay for some things to not work fully until you push the changes to the production environment.

You shouldn't be trying to tie the Drupal permission scheme and your user account permission scheme together. Let the production Drupal stuff live in /var/www/html or wherever, with all the permissions that make Apache/PHP/Drupal happy. Let your development tree be owned by you.

Whenever you finish work on a new feature for the web site, use some sort of synchronization tool to push the changes from dev to production, incidentally getting new permissions along the way.

Personally, I use rsync for this. That has the nice advantage that the production server can be across the Internet, since tunneling rsync through ssh is trivial. That's an important feature with web development, since there are usually good reasons to host your web site on a server not on your own LAN. I use a command like this for my sites:

rsync -lprtvD -e ssh --delete \
        --exclude \*.swp \
        --exclude .svn \
        --exclude GNUmakefile \
        ./ [email protected]:/var/www/html

That command will make the files be owned by the www user on www.mysite.com, decoupling the dev permission scheme from production.

It sounds like you want to use SVN instead, which is fine. You just have to make it so the dev and production boxes can both see the SVN server. As with rsync, you want to be tunneling the SVN protocol through ssh here, for security. When it's time to push a change to production, check it into SVN, then check it out on the production box. Actually, I'd recommend using svn export instead of svn checkout to avoid scattering .svn subdirectories all over your web server tree. The rsync method avoids that with --exclude rules.

2
  • Thanks, I'm now using rsync. However I got an error: rsync error: some files could not be transferred (code 23). How do I know which files have not been transferred and why ?
    – aneuryzm
    Jan 7, 2011 at 9:12
  • You should probably post a separate question asking about rsync error 23. I've never had it happen, but if I had, I'd add one or more v's to the option set. You can add up to 3, each increasing the verbosity of rsync. Due to rsync's nature, running it multiple times won't hurt. Just keep increasing the verbosity until it tells you something helpful. Jan 7, 2011 at 20:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .