apache 无法打开文件“svn/repo/db/txn-current-lock”:权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/960241/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't open file 'svn/repo/db/txn-current-lock': Permission denied
提问by wsd
I have set up a Linux Server and installed Apache and SVN and dav_svn on it. Now, when I try to upload to https://x.x.x.x:x/svn/repowith Tortoise SVN I get
我已经设置了一个 Linux 服务器并在其上安装了 Apache 和 SVN 以及 dav_svn。现在,当我尝试https://x.x.x.x:x/svn/repo使用 Tortoise SVN上传时,我得到
Can't open file '/server/svn/repo/db/txn-current-lock': Permission denied
I have Set up my SSL correctly (I can checkout, no problems, even remotely due to Port Forwarding).
我已经正确设置了我的 SSL(我可以结帐,没有问题,甚至由于端口转发而远程)。
I'm guessing this has to do with the Linux Ownership of the Repository folders, How must I set this/ what are the commands?
我猜这与 Repository 文件夹的 Linux 所有权有关,我必须如何设置/命令是什么?
回答by John Feminella
This is a common problem. You're almost certainly running into permissions issues. To solve it, make sure that the apacheuser has read/write access to your entire repository. To do that, chown -R apache:apache *, chmod -R 664 *for everything under your svn repository.
这是一个常见的问题。您几乎肯定会遇到权限问题。要解决它,请确保apache用户对整个存储库具有读/写访问权限。要做到这一点,chown -R apache:apache *,chmod -R 664 *为你的svn库下的一切。
Also, see hereand hereif you're still stuck.
Update to answer OP's additional question in comments:
更新以在评论中回答 OP 的其他问题:
The "664" string is an octal (base 8) representation of the permissions. There are three digits here, representing permissions for the owner, group, and everyone else(sometimes called "world"), respectively, for that file or directory.
“664”字符串是权限的八进制(基数为 8)表示。这里有三位数字,分别代表该文件或目录的所有者、组和其他所有人(有时称为“世界”)的权限。
Notice that each base 8 digit can be represented with 3 bits (000 for '0' through 111 for '7'). Each bit means something:
请注意,每个基数为 8 的数字都可以用 3 位表示(000 表示“0”到 111 表示“7”)。每一位都意味着:
- first bit: read permissions
- second bit: write permissions
- third bit: execute permissions
- 第一位:读取权限
- 第二位:写权限
- 第三位:执行权限
For example, 764 on a file would mean that:
例如,文件上的 764 意味着:
- the owner (first digit) has read/write/execute (7) permission
- the group (second digit) has read/write (6) permission
- everyone else (third digit) has read (4) permission
- 所有者(第一位)具有读/写/执行 (7) 权限
- 该组(第二位数字)具有读/写 (6) 权限
- 其他人(第三位)已阅读 (4) 权限
Hope that clears things up!
希望这能说明问题!
回答by mezek
It's permission problem. It is not "classic" read/write permissions of apache user, but selinux one.
是权限问题。它不是 apache 用户的“经典”读/写权限,而是 selinux 权限。
Apache cannot write to files labeled as httpd_sys_content_tthey can be only read by apache.
Apache 无法写入标记为httpd_sys_content_t只能由 apache 读取的文件。
You have 2 possibilities:
你有两种可能:
label svn repository files as
httpd_sys_content_rw_t:chcon -R -t httpd_sys_content_rw_t /path/to/your/svn/reposet selinux boolean
httpd_unified --> onsetsebool -P httpd_unified=1
将 svn 存储库文件标记为
httpd_sys_content_rw_t:chcon -R -t httpd_sys_content_rw_t /path/to/your/svn/repo设置 selinux 布尔值
httpd_unified --> onsetsebool -P httpd_unified=1
I prefer 2nd possibility. You can play also with other selinux booleans connected with httpd:
我更喜欢第二种可能性。您还可以使用与httpd以下连接的其他 selinux 布尔值:
getsebool -a | grep httpd
回答by user2169568
I also had this problem recently, and it was the SELinux which caused it. I was trying to have the post-commit of subversion to notify Jenkins that the code has change so Jenkins would do a build and deploy to Nexus.
我最近也遇到了这个问题,是 SELinux 导致的。我试图让 subversion 提交后通知 Jenkins 代码已经更改,以便 Jenkins 进行构建并部署到 Nexus。
I had to do the following to get it to work.
我必须执行以下操作才能使其正常工作。
1) First I checked if SELinux is enabled:
1)首先我检查是否启用了 SELinux:
less /selinux/enforce
This will output 1 (for on) or 0 (for off)
这将输出 1(打开)或 0(关闭)
2) Temporary disable SELinux:
2) 暂时禁用 SELinux:
echo 0 > /selinux/enforce
Now test see if it works now.
现在测试看看它现在是否有效。
3) Enable SELinux:
3) 启用 SELinux:
echo 1 > /selinux/enforce
Change the policy for SELinux.
更改 SELinux 的策略。
4) First view the current configuration:
4)首先查看当前配置:
/usr/sbin/getsebool -a | grep httpd
This will give you: httpd_can_network_connect --> off
这会给你: httpd_can_network_connect --> off
5) Set this to on and your post-commit will work with SELinux:
5) 将此设置为 on,您的提交后将适用于 SELinux:
/usr/sbin/setsebool -P httpd_can_network_connect on
Now it should be working again.
现在它应该可以再次工作了。
回答by puchu
for example on debian
例如在 debian
sudo gpasswd -a svn-admin www-data
sudo chgrp -R www-data svn/
sudo chmod -R g=rwsx svn/
回答by Lofty Lion
In addition to the repository permissions, the /tmpdirectory must also be writeable by all users.
除了存储库权限之外,该/tmp目录还必须可由所有用户写入。
回答by vladimir
Try to disable SELinux by this command /usr/sbin/setenforce 0. In my case it solved the problem.
尝试通过此命令禁用 SELinux /usr/sbin/setenforce 0。就我而言,它解决了问题。
回答by Pascal
I just had this problem
我刚遇到这个问题
- Having multiple user using the same repo caused the problem
- Logout evey other user using the repo
- 有多个用户使用同一个 repo 导致了问题
- 使用 repo 注销每个其他用户
Hope this helps
希望这可以帮助
回答by Dreem Job
3 Steps you can follow
您可以遵循的 3 个步骤
chmod -R 775 <repo path> ---> change permissions of repositorychown -R apache:apache <repo path> ---> change owner of svn repositorychcon -R -t httpd_sys_content_t <repo path> ----> change SELinux security context of the svn repository
chmod -R 775 <repo path> ---> change permissions of repositorychown -R apache:apache <repo path> ---> change owner of svn repositorychcon -R -t httpd_sys_content_t <repo path> ----> change SELinux security context of the svn repository

