【发布时间】:2018-09-13 07:46:57
【问题描述】:
我在我的 Centos 7 VPS 上创建了一个 wordpress 登台遥控器。 Wordpress 安装在此目录/var/www/html 中,组/所有者是默认的apache:apache。
然后我在~/git/repo 和post-receive 上创建了一个裸git repo,并在hooks 中使用这个bash 脚本:
#!/bin/sh
TARGET=/var/www/html/wp-content
GIT_DIR=/home/username/git/repo
#(1) Change directory's ownership to allow writing
sudo chown -R username:apache /var/www/html
#run 'post-receive' hook
git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f
#(2) return to original
sudo chown -R apache:apache /var/www/html
让我解释一下。
(1) = 因为否则我无法在该目标目录中写入任何内容,所以我必须将所有权更改为我当前的用户名。
(2) = 因为否则,通过维护 username:apache 我无法通过 wordpress 管理前端安装任何东西:FTP 权限凭据输入。
在我的本地环境中,我在 wordpress 安装的wp-content 创建了工作 git 存储库并链接到远程。
现在,问题是当我使用 GIT bash 或 Sourcetree 推送更改时,文件被传输到裸远程仓库,但接收后脚本由于其 sudo 命令而失败。
你对我有什么建议?
【问题讨论】:
-
没人能帮我解决这个问题吗?
标签: wordpress git git-remote git-post-receive git-bare