Linux-git安裝篇--以及編譯安裝失敗處理


Linux環境的git安裝有多種方法:1,yum install git*,這樣的方法是有局限性,據說yum源中安裝的git版本是1.7.1,Github等需要的Git版本最低都不能低於1.7.2,我的虛擬機系統版本是CentOS6,yum源里是沒有git可供下載的,所以我們現在考慮方法2或者方法3;2, 雲端下載git版本,然后解壓編譯。3,網上下載git版本,然后導入Linux的指定目錄下,解壓編譯

下面的方法都是方法2/3需要經歷的過程:

1.安裝yum依賴包

 需要擁有一定的權限,這里我用的是root權限,

  yum install zlib-devel 
  yum install openssl-devel 
  yum install perl 
  yum install cpio 
  yum install expat-devel 
  yum install gettext-devel 
  yum install autoconf 

2.下載git源碼

wget https://github.com/git/git/archive/v2.3.0.zip

 unzip v2.3.0.zip

 cd git-2.3.0

3.編譯安裝git

將其安裝在“/usr/local/git”目錄下。

make prefix=/usr/local/git all

make prefix=/usr/local/git install

這里有可以會報錯:

usr/bin/perl Makefile.PL PREFIX='/usr/local/git' INSTALL_BASE='' --localedir='/usr/local/git/share/locale'

Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.

BEGIN failed--compilation aborted at Makefile.PL line 3.

make[1]: *** [perl.mak] Error 2

make: *** [perl/perl.mak] Error 2

解決方法:

安裝依賴包:yum install perl-ExtUtils-MakeMaker package.

然后再重新編譯安裝git:

make prefix=/usr/local/git all

make prefix=/usr/local/git install

4.配置環境變量

 進入環境變量配置文件:vim /etc/profile

 pATH里添加git的指定路徑:我的路徑是,/usr/local/git/bin

  source /etc/profile:這個命令是讓修改的文件生效

 完了之后查看git是否安裝成功:git --version

 5.生成SSH密鑰過程

[root@localhost bin]# git config --global user.name "oscar.xie"
[root@localhost bin]# git config --global user.email "oscar.xie@amoby.com"
[root@localhost bin]# cd ~/.ssh
-bash: cd: /root/.ssh: No such file or directory
[root@localhost bin]# ssh-keygen -t rsa -C “oscar.xie@amoby.com”
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):   這里輸入回車
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):            這里輸入回車
Enter same passphrase again:                                   這里輸入回車   3個回車輸入表示密碼為空!

Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
74:e9:ef:c5:f3:73:df:93:51:42:92:4b:ad:c4:c5:f5 “oscar.xie@amoby.com”
The key's randomart image is:
+--[ RSA 2048]----+
| . =...|
| .* + .|
| . oo = E|
| . o o . .|
| S . ..|
| . . . |
| . + o|
| . . *o|
| . O|
+-----------------+
[root@localhost bin]# cd ~/.ssh
[root@localhost .ssh]# ll
total 8
-rw-------. 1 root root 1679 Nov 19 19:37 id_rsa
-rw-r--r--. 1 root root 407 Nov 19 19:37 id_rsa.pub

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM