LoginSignup
20
20

More than 5 years have passed since last update.

Gitをソースからコンパイルしてインストールする

Posted at

リポジトリが腐っているディストリビューションがある(例えば、CentOS)
自力で入れられないことがある(例えば、さくらのレンタルサーバ・研究室・仕事のサーバ)
なんかリポジトリを整理してyumコマンドとかportコマンドでインストールするのも
面倒っていうときにソースからインストールしちまおうってたまに思うから書こうと思った。

ちなみに僕のだとこんな環境。さくらのレンタルサーバ。

$ uname -a
FreeBSD www280.sakura.ne.jp 7.1-RELEASE-p16 FreeBSD 7.1-RELEASE-p16 #0: Fri May  4 06:01:53 JST 2012     root@www280sub.sakura.ne.jp:/usr/obj/usr/src/sys/SAKURA11S  i386
$ which git
/home/zange-box/local/bin/git
$ git --version
git version 1.7.2.1

gitは自分でいれたっぽいけど古いし入れなおす。

http://git-scm.com/ から
http://code.google.com/p/git-core/downloads/list に行き
http://code.google.com/p/git-core/downloads/detail?name=git-1.7.11.3.tar.gz&can=2&q= ここまでたどり着く

$ wget http://git-core.googlecode.com/files/git-1.7.11.3.tar.gz
$ tar xf git-1.7.11.3.tar.gz
$ cd git-1.7.11.3

INSTALLのなかをみる

$ less INSTALL
                Git installation

Normally you can just do "make" followed by "make install", and that
will install the git programs in your own ~/bin/ directory.  If you want
to do a global install, you can do

        $ make prefix=/usr all doc info ;# as yourself
        # make prefix=/usr install install-doc install-html install-info ;# as root

こんなの書いてある。なるほど英語よくわからん。
とりあえずいつもの。

$ ./configure --prefix=~/local # ~/以下にlocalディレクトリつくってね
$ gmake # CentOSならmakeかな?
$ gmake install # make install

正常にインストールできたぽかったら、PATHを確認する

$ echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/zange-box/bin:/home/zange-box/local/bin:/home/zange-box/bin:/home/zange-box/pear/bin:/home/zange-box/pear/pear

長いけど /home/zange-box/local/bin がある
大丈夫そう。
$ ./configure --prefix=で指定したディレクトリがなかったら

$ emacs ~/.bashrc

export PATH=$HOME/local/bin:$PATH を追加してあげる

$ git --version
git version 1.7.11.3

最新のgitになった。心が安らぐ。

まとめ

  • gitは常に最新版を使う
    • 最新版のほうが親切
  • アレなOSはリポジトリをいじいじするよりもソースからインストールするほうが早い

ちなみに

$ git --version
git version 1.7.7.5 (Apple Git-26)
$ brew update
$ brew install git
$ git --version
git version 1.7.11.3
20
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
20