git をソースからインストールする方法

CentOS 5.4 に git をインストールしようと思って、下記コマンドを実行してみました。

yum install git-1.5.6.1-1 --enablerepo=rpmforge

エラーです…。checksum がなんとかって。いろいろ調べたんですがうまくいかなくて、結局ソースからインストールすることに。
linuxにgitをインストール を参考に、ソースで入れてみます。

1. git の最新を確認。1.6.5.6 だそうなので、/usr/local/src に移動して、それを入れます。

[root@localhost]# cd /usr/local/src
[root@localhost src]#wget http://kernel.org/pub/software/scm/git/git-1.6.5.6.tar.gz
[root@localhost src]tar zxvf git-1.6.5.6.tar.gz
[root@localhost src] cd git-1.6.5.6
[root@localhost git-1.6.5.6]# ./configure
configure: Setting lib to 'lib' (the default)
configure: Will try -pthread then -lpthread to enable POSIX Threads.
configure: CHECKS for site configuration
configure: CHECKS for programs
checking for cc... no
checking for gcc... no
configure: error: in `/usr/local/src/git-1.6.5.6':
configure: error: no acceptable C compiler found in $PATH


2. またエラーです。gcc がないとか言われてるので、インストールします。

[root@localhost git-1.6.5.6]# yum install gcc


3. 警告とか出てたけど、とりあえずインストール完了。yum でインストールできたので、git がインストールできなかったのは yum のせいじゃないようです。もう一度、./configure を実行します。

[root@localhost git-1.6.5.6]# ./configure


4. 通ったので、make します。

[root@localhost git-1.6.5.6]# make
Error: zlib.h: No such file or directory


5. 今度は zlib がないと言われたので、インストールします。

[root@localhost git-1.6.5.6]# yum install zlib


6. すでに入ってるよ、とメッセージが。でもないって言われてるので、だめもとで下記を実行してみます。

[root@localhost git-1.6.5.6]# yum install zlib-devel


7. うまくいったみたいなので、今度こそ make して、make install します。

[root@localhost git-1.6.5.6]# make
[root@localhost git-1.6.5.6]# make install


8. 問題なく終了。バージョンも確認できたので、OK とします。man コマンド使えないけど、そのうち対応します…。

[root@localhost git-1.6.5.6]# git --version
git version 1.6.5.6