问题
I'm currently building a ubuntu (10.0.4 LTS) server on a VPS to host a WordPress based website.
I've got gitosis installed to host the remote repository and what I would like to do is plugin to the post receive hook to update the WordPress theme when I git push.
I'm getting a bit confused with users and permissions. As when we I run git pull the files in /var/www will be owned by the git user. Ideally I would like all files in the /var/www to be owned by the same user as I think this would be safer?
I've currently got the /var/www folder owned my the www-data user, after some reading I've realised this is not the best thing to do. I need a bit of help working out the best plan of action for this?
回答1:
From the comments:
I wouldn't use gitosis for that kind of fine-grained control:
- gitosis is obsolete and not moving since 2009 (even though some forks are still a bit active)
- This comment and that question illustrate that most features are easier to do with Gitolite.
So, with Gitolite:
The umask use for the Git repo checked out by the git user within a gitolite environment will be the one described in the doc section "most often used/changed variables"
The default
UMASKthat gitolite uses makes all the repos and their contents haverwx------permissions. People who want to rungitwebrealise that this will not do.The correct way to deal with this is to give this variable a value like
0027(note the syntax: the leading0is required), and then make the user running the webserver (apache,www-data, whatever) a member of the 'git' group.If you've already installed gitolite then existing files will have to be fixed up manually (for a
umaskor0027, that would bechmod -R g+rX).
This is becauseumaskonly affects permissions on newly created files, not existing ones.
From there, you can follow "install gitolite under "apache"".
来源:https://stackoverflow.com/questions/9927981/gitosis-and-www-data