1

誰かが助けてくれることを望んでいshell_execました。ディレクトリを圧縮して実行git pullし、最近のリポジトリの変更を停止するために使用するPHPページがあります。

$op = shell_exec("cd /home/user/git/$repo/$dir/; zip -r /home/user/archives/$dir.$datestamp.zip $dir; cd /home/user/git/$repo/$dir/; git pull");

zipは正常に機能します。git pullたとえば、shell_exec内でgit logまたは-に変更すると、これも機能し、ログファイルを確認できます。git status

gitpullが好きではないようです。

私はこれに似た別の投稿を見ましたが、それがどのように達成されたかわかりませんでした>> git pullを使用したShell_exec?

4

1 に答える 1

4

apacheコメントの説明から、問題はユーザーがリポジトリに書き込めないことであるように思われます。これは、を使用するときに明らかに必要ですgit pull。2つの行動方針があります。

  1. 別のユーザーとしてスクリプトを実行するようにApacheをセットアップします(たとえば、VirtualHostまたはuserdirを介してsuEXECを使用します)
  2. apacheユーザーがリポジトリに書き込めるように、リポジトリの権限を変更します

どちらを選択してもセキュリティへの影響を慎重に検討する必要がありますが、2番目のオプションがおそらく最も簡単です。そのようなグループをまだ持っていない場合は、次のコマンドで作成できます。

addgroup gitwriters

...次に、自分自身とApacheユーザーをこのグループに追加します。

adduser [yourusername] gitwriters
adduser apache gitwriters

次に、別の質問の指示に従って、リポジトリの権限を変更できます。若干の違いがあるものを繰り返すには:

# Recursively, set the group ownership of every file and directory of your repository:
chgrp -R gitwriters /path/to/your/repo

# Recursively, make every file and directory of your repository readable and writable
# by the group:
chmod -R g+rw /path/to/your/repo

# Recursively, set the setgid of every directory in the repository.  The setgid bit
# on directories means that files created in the directory will have the same group
# ownership as the directory.  
find /path/to/your/repo -type d -print0 | xargs -0 chmod g+s

その後、うまくいけばあなたはうまくgit pullいくはずです。

于 2011-02-28T20:25:14.973 に答える