MAMP卒業しよう、と言っているのにMAMPで記事を書く。
VirtualHost使えよってところだけど、ScriptAriasでやる。
おまけに今回、目的を果たせなかった。
ということで役に立たない内容かと思いますが、とりあえず。# 背景 #
ってほどのことはないけど、Mercurialしか使ってこなかったけれど、今後Gitも使うことになりそうなので、練習にgitの共有リポジトリとか欲しいかな。GitHubでも良いんだけど、もう少し使い方を知ってからじゃないと、変なミスして、恥ずかしいだけなら良いけど、なんか迷惑とかかかったりしないかなー的不安が(早速間違ってforkしちゃった)。というわけで、自分環境としてGitでのhgwebっぽいgitwebってのがあるみたい。これで練習しよう。(結局、徒労だったので結果へ)
なんでMAMPか
以前にMAMP導入(アプリケーション開くだけだけど)してからそのままだから。hgwebもMAMPにあるし。
作業
- Gitを入れる(Homebrew)
<pre class=\"brush: bash; gutter: false; first-line: 1; highlight: []; html-script: false\"> $ brew install git</pre>
- 共有リポジトリを作る
<pre class=\"brush: bash; gutter: false; first-line: 1; highlight: []; html-script: false\"> $ cd [共有リポジトリを入れていくディレクトリへのパス]
$ mkdir hoge.git
$ cd hoge.git
# git init --bare --shared=true</pre>
- なんかコミットプッシュしておく
<pre class=\"brush: bash; gutter: false; first-line: 1; highlight: []; html-script: false\"> $ cd [仕事するディレクトリ]
$ git clone [hoge.gitへのパス]
$ cd hoge
$ touch README.md
$ git add .
$ git commit -m \'Init\'
$ git push origin master</pre>
- MAMPのApacheでCGIが動くところにgitweb.cgiをコピーする。
<pre class=\"brush: bash; gutter: false; first-line: 1; highlight: []; html-script: false\"> $ cd /Applications/MAMP/cgi-bin
$ mkdir git;cd git
$ cp /usr/local/share/gitweb/gitweb.cgi ./</pre>
- gitwebのcgi以外をどっかMAMPのapacheが読める所にコピーする
<pre class=\"brush: bash; gutter: false; first-line: 1; highlight: []; html-script: false\"> $ cp -a /usr/local/share/gitweb/static /Applications/MAMP/htdocs/static</pre>
- httpd.confにScriptAriasを設定する
$ vi /Applications/MAMP/conf/apache/httpd.conf
以下みたいなのを追加。
(ついでにBasic認証かけた。
$ htpassword -c /Applications/MAMP/conf/htpasswd/git/.htpasswd ohton)
<pre class=\"brush: ; gutter: false; first-line: 1; highlight: []; html-script: false\">ScriptAlias /git \"/Applications/MAMP/cgi-bin/git/gitweb.cgi\"
<Directory \"/Applications/MAMP/cgi-bin/git\">
AuthType Basic
AuthUserFile /Applications/MAMP/conf/htpasswd/git/.htpasswd
AuthGroupFile /dev/null
AuthName \"Please enter your ID and password\"
Require valid-user
</Directory></pre>
MAMPのApache再起動。
1. gitwebの設定
もともとあるgitweb.cgiを使うなら、/etc/gitweb.conf を作ってやれば良いらしい。今回はMAMPのcgi-binにコピーしたものを使うので、コピーしたgitweb.cgiを編集する。
<pre class=\"brush: bash; gutter: false; first-line: 1; highlight: []; html-script: false\"> $ vi /Applications/MAMP/cgi-bin/git/gitweb.cgi</pre>
以下を編集する。
our $projectroot = \"[共有リポジトリを入れていくディレクトリへのパス]\";
とりあえずこれだけで見れるようにはなった。
あれ?でもこれ、見れるけど、どこみてcloneすれば良いんだ??
なんかこのままだと出来ないっぽい。
うまくやりたいなら、
gitolite とか gitosis とか GitLab とかがキーワードっぽい。面倒くさそうな予感。
結果
hgwebを普通に動かしただけだと、\”見れる\”だけだった。
gitolite とか gitosis とか GitLab とやらを調べてからまたやろう。
どうもgitが好きになれない予感が。
Mercurialで良いじゃんか~。