如何在 CENTOS 5.5 上安装 git?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3779274/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 09:08:56  来源:igfitidea点击:

How can git be installed on CENTOS 5.5?

gitcentos5

提问by Prakash

How can I install git on CENTOS 5.5 machine? I tried to install it from yum but got following msg.

如何在 CENTOS 5.5 机器上安装 git?我尝试从 yum 安装它,但收到了以下消息。

root@host [~]# sudo yum install git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: centos.mirrors.tds.net
 * base: mirror.ubiquityservers.com
 * extras: mirrors.serveraxis.net
 * updates: pubmirrors.reflected.net
addons                                                   |  951 B     00:00
base                                                     | 2.1 kB     00:00
extras                                                   | 2.1 kB     00:00
updates                                                  | 1.9 kB     00:00
Excluding Packages in global exclude list
Finished
Setting up Install Process
No package git available.
Nothing to do
root@host [~]#

采纳答案by eldarerathis

From source? From the repos? The easiest way is to use the repos: sudo yum install gitshould do it. It may first be necessary to set up an additional repo such as EPELfirst if git is not provided by the main repos.

从源头?从回购?最简单的方法是使用 repos: sudo yum install gitshould do it。如果主存储库未提供 git,则可能首先需要设置额外的存储库,例如EPEL

If you want to install from source, you can try theseinstructions. If you have yum-utilsinstalled it's actually easier than that, too**:

如果您想从源代码安装,您可以尝试这些说明。如果您已经yum-utils安装,它实际上也比这更容易**:

sudo yum build-dep git
wget http://kernel.org/pub/software/scm/git/<latest-git-source>.tar.gz
tar -xvjf <latest-git>.tar.gz
cd <git>
make (possibly a ./configure before this)
sudo make install

**Substitute the portions enclosed in <>with the paths you need. Exact procedure may vary slightly as I have not compiled git from source, personally (there may be a configure script, for example). If you have no idea what I'm talking about, then you may want to just install from the repo as per my first suggestion.

**<>用您需要的路径替换封闭的部分。确切的过程可能会略有不同,因为我个人没有从源代码编译 git(例如,可能有一个配置脚本)。如果您不知道我在说什么,那么您可能只想按照我的第一个建议从 repo 安装。

回答by rjzii

If you are using CentOS the built in yumrepositories don't seem to have gitincluded and as such, you will need to add an additional repository to the system. For my servers I found that the Webtaticrepository seems to be reasonably up to date and the installation for gitwill then be as follows:

如果您使用 CentOS,内置软件yum库似乎没有git包含在内,因此您需要向系统添加一个额外的软件库。对于我的服务器,我发现Webtatic存储库似乎是最新的,git然后安装如下:

# Add the repository
rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm

# Install the latest version of git
yum install --enablerepo=webtatic git-all

To work around Missing Dependency: perl(Git)errors:

要解决Missing Dependency: perl(Git)错误:

yum install --enablerepo=webtatic --disableexcludes=main  git-all

回答by Santiago Corredtheitroada

Just:

只是:

sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
sudo yum install git-core

回答by Datageek

I've tried few methods from this question and they all failed on my CentOs, either because of the wrong repos or missing files.

我已经尝试过这个问题中的几种方法,但它们在我的 CentO 上都失败了,要么是因为错误的存储库要么是丢失的文件。

Here is the method which works for me (when installing version 1.7.8):

这是对我有用的方法(安装版本 1.7.8 时):

    yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel
    wget http://git-core.googlecode.com/files/git-1.7.8.tar.gz
    tar -xzvf ./git-1.7.8.tar.gz
    cd ./git-1.7.8
    ./configure
    make
    make install 

You may want to download a different version from here: http://code.google.com/p/git-core/downloads/list

您可能想从这里下载不同的版本:http: //code.google.com/p/git-core/downloads/list

回答by pondoklukman

For installing git

用于安装 git

  1. install last epel-release
  1. 安装最后一个 epel-release

rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

  1. Install git from repository
  1. 从存储库安装 git

yum install git

yum 安装 git

回答by Dale Anderson

I'm sure this question is about to die now that RHEL 5 is nearing end of life, but the answer seems to have gotten a lot simpler now:

我确信这个问题现在 RHEL 5 即将结束,但现在答案似乎变得简单了很多:

sudo yum install epel-release
sudo yum install git

worked for me on a fresh install of CentOS 5.11.

在全新安装的 CentOS 5.11 上对我来说有效。

回答by nathan

yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel gcc
wget http://git-core.googlecode.com/files/git-1.7.11.4.tar.gz
tar zxvf git-1.7.11.4.tar.gz 
cd git-1.7.11.4
./configure 
make
make install

回答by Anthony Skjellum

OK, there is more to it than that, you need zlib. zlib is part of CentOS, but you need the development form to get zlib.h ... notice that the yum name of zlib development is quite different possibly than for apt-get on ubuntu/debian, what follows actually works with my CentOS version
in particular, you do ./configure on git, then try make, and the first build fails with missing zlib.h

好的,还有更多,你需要 zlib。zlib 是 CentOS 的一部分,但你需要开发表格来获取 zlib.h ... 注意 zlib 开发的 yum 名称可能与 ubuntu/debian 上的 apt-get 完全不同,下面的内容实际上适用于我的 CentOS 版本
特别是,您在 git 上执行 ./configure,然后尝试 make,并且第一个构建失败并缺少 zlib.h

I used a two-step procedure to resolve this a) Got RPMFORGE for my version of CentOS

我使用了一个两步程序来解决这个问题 a) 为我的 CentOS 版本获得了 RPMFORGE

See: www.centos.org/modules/newbb/viewtopic.php?topic_id=18506&forum=38 and this: wiki.centos.org/AdditionalResources/Repositories/RPMForge

请参阅:www.centos.org/modules/newbb/viewtopic.php?topic_id=18506&forum=38 以及:wiki.centos.org/AdditionalResources/Repositories/RPMForge

In my case [as root, or with sudo]

在我的情况下 [作为 root,或使用 sudo]

$ wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
$ rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm
$ rpm -i rpmforge-release-0.5.2-2.el5.rf.*.rpm
## Note: the RPM for rpmforge is small (like 12.3K) but don't let that fool
## you; it augments yum the next time you use yum
## [this is the name that YUM found] (still root or sudo)
$ yum install zlib-devel.x86_64
## and finally in the source directory for git (still root or sudo):
$ ./configure (this worked before, but I ran it again to be sure)
$ make
$ make install

(this install put it by default in /usr/local/bin/git... not my favorite choice, but OK for the default)... and git works fine!

(这个安装默认将它放在/usr/local/bin/git......不是我最喜欢的选择,但默认情况下可以)......并且git工作正常!

回答by jww

It looks like the repos for CentOS 5 are disappearing. Most of the ones mentioned in this question are no longer online, don't seem to have Git, or have a really old version of Git. Below is the script I use to build OpenSSL, IDN2, PCRE, cURL and Git from sources. Both the git://and https://protocols will be available for cloning.

看起来 CentOS 5 的存储库正在消失。这个问题中提到的大多数不再在线,似乎没有Git,或者有一个非常旧的Git版本。下面是我用来从源代码构建 OpenSSL、IDN2、PCRE、cURL 和 Git 的脚本。无论是git://https://协议将可用于克隆。

Over time the names of the archives will need to be updates. For example, as of this writing, openssl-1.0.2k.tar.gzis the latest available in the 1.0.2 family.

随着时间的推移,档案的名称将需要更新。例如,在撰写本文时,它openssl-1.0.2k.tar.gz是 1.0.2 系列中最新可用的。

Dale Anderson's answer using RHEL repos looks good at the moment, but its a fairly old version. Red Hat provides Git version 1.8, while the script below builds 2.12 from sources.

戴尔安德森使用 RHEL 存储库的回答目前看起来不错,但它是一个相当旧的版本。Red Hat 提供 Git 版本 1.8,而下面的脚本从源代码构建 2.12。



#!/usr/bin/env bash

# OpenSSL installs into lib64/, while cURL installs into lib/
INSTALL_ROOT=/usr/local
INSTALL_LIB32="$INSTALL_ROOT/lib"
INSTALL_LIB64="$INSTALL_ROOT/lib64"

OPENSSL_TAR=openssl-1.0.2k.tar.gz
OPENSSL_DIR=openssl-1.0.2k

ZLIB_TAR=zlib-1.2.11.tar.gz
ZLIB_DIR=zlib-1.2.11

UNISTR_TAR=libunistring-0.9.7.tar.gz
UNISTR_DIR=libunistring-0.9.7

IDN2_TAR=libidn2-0.16.tar.gz
IDN2_DIR=libidn2-0.16

PCRE_TAR=pcre2-10.23.tar.gz
PCRE_DIR=pcre2-10.23

CURL_TAR=curl-7.53.1.tar.gz
CURL_DIR=curl-7.53.1

GIT_TAR=v2.12.2.tar.gz
GIT_DIR=git-2.12.2

###############################################################################

# I don't like doing this, but...
read -s -p "Please enter password for sudo: " SUDO_PASSWWORD

###############################################################################

echo
echo "********** zLib **********"

wget "http://www.zlib.net/$ZLIB_TAR" -O "$ZLIB_TAR"

if [[ "$?" -ne "0" ]]; then
    echo "Failed to download zLib"
    [[ "
sudo rpm -Uvh http://archives.fedoraproject.org/pub/archive/epel/5/x86_64/epel-release-5-4.noarch.rpm
sudo yum install git
" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi rm -rf "$ZLIB_DIR" &>/dev/null tar -xzf "$ZLIB_TAR" cd "$ZLIB_DIR" LIBS="-ldl -lpthread" ./configure --enable-shared --libdir="$INSTALL_LIB64" if [[ "$?" -ne "0" ]]; then echo "Failed to configure zLib" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi make -j 4 if [ "$?" -ne "0" ]; then echo "Failed to build zLib" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi echo "$SUDO_PASSWWORD" | sudo -S make install cd .. ############################################################################### echo echo "********** Unistring **********" # https://savannah.gnu.org/bugs/?func=detailitem&item_id=26786 wget "https://ftp.gnu.org/gnu/libunistring/$UNISTR_TAR" --no-check-certificate -O "$UNISTR_TAR" if [[ "$?" -ne "0" ]]; then echo "Failed to download IDN" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi rm -rf "$UNISTR_DIR" &>/dev/null tar -xzf "$UNISTR_TAR" cd "$UNISTR_DIR" LIBS="-ldl -lpthread" ./configure --enable-shared --libdir="$INSTALL_LIB64" if [[ "$?" -ne "0" ]]; then echo "Failed to configure IDN" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi make -j 4 if [ "$?" -ne "0" ]; then echo "Failed to build IDN" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi echo "$SUDO_PASSWWORD" | sudo -S make install cd .. ############################################################################### echo echo "********** IDN **********" # https://savannah.gnu.org/bugs/?func=detailitem&item_id=26786 wget "https://alpha.gnu.org/gnu/libidn/$IDN2_TAR" --no-check-certificate -O "$IDN2_TAR" if [[ "$?" -ne "0" ]]; then echo "Failed to download IDN" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi rm -rf "$IDN2_DIR" &>/dev/null tar -xzf "$IDN2_TAR" cd "$IDN2_DIR" LIBS="-ldl -lpthread" ./configure --enable-shared --libdir="$INSTALL_LIB64" if [[ "$?" -ne "0" ]]; then echo "Failed to configure IDN" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi make -j 4 if [ "$?" -ne "0" ]; then echo "Failed to build IDN" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi echo "$SUDO_PASSWWORD" | sudo -S make install cd .. ############################################################################### echo echo "********** OpenSSL **********" wget "https://www.openssl.org/source/$OPENSSL_TAR" -O "$OPENSSL_TAR" if [[ "$?" -ne "0" ]]; then echo "Failed to download OpenSSL" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi rm -rf "$OPENSSL_DIR" &>/dev/null tar -xzf "$OPENSSL_TAR" cd "$OPENSSL_DIR" # OpenSSL and enable-ec_nistp_64_gcc_12 option IS_X86_64=$(uname -m 2>&1 | egrep -i -c "(amd64|x86_64)") CONFIG=./config CONFIG_FLAGS=(no-ssl2 no-ssl3 no-comp shared "-Wl,-rpath,$INSTALL_LIB64" --prefix="$INSTALL_ROOT" --openssldir="$INSTALL_ROOT") if [[ "$IS_X86_64" -eq "1" ]]; then CONFIG_FLAGS+=("enable-ec_nistp_64_gcc_128") fi "$CONFIG" "${CONFIG_FLAGS[@]}" if [[ "$?" -ne "0" ]]; then echo "Failed to configure OpenSSL" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi make depend make -j 4 if [ "$?" -ne "0" ]; then echo "Failed to build OpenSSL" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi echo "$SUDO_PASSWWORD" | sudo -S make install_sw cd .. ############################################################################### echo echo "********** PCRE **********" # https://savannah.gnu.org/bugs/?func=detailitem&item_id=26786 wget "https://ftp.pcre.org/pub/pcre//$PCRE_TAR" --no-check-certificate -O "$PCRE_TAR" if [[ "$?" -ne "0" ]]; then echo "Failed to download PCRE" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi rm -rf "$PCRE_DIR" &>/dev/null tar -xzf "$PCRE_TAR" cd "$PCRE_DIR" make configure CPPFLAGS="-I$INSTALL_ROOT/include" LDFLAGS="-Wl,-rpath,$INSTALL_LIB64 -L$INSTALL_LIB64" \ LIBS="-lidn2 -lz -ldl -lpthread" ./configure --enable-shared --enable-pcre2-8 --enable-pcre2-16 --enable-pcre2-32 \ --enable-unicode-properties --enable-pcregrep-libz --prefix="$INSTALL_ROOT" --libdir="$INSTALL_LIB64" if [[ "$?" -ne "0" ]]; then echo "Failed to configure PCRE" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi make all -j 4 if [ "$?" -ne "0" ]; then echo "Failed to build PCRE" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi echo "$SUDO_PASSWWORD" | sudo -S make install cd .. ############################################################################### echo echo "********** cURL **********" # https://savannah.gnu.org/bugs/?func=detailitem&item_id=26786 wget "https://curl.haxx.se/download/$CURL_TAR" --no-check-certificate -O "$CURL_TAR" if [[ "$?" -ne "0" ]]; then echo "Failed to download cURL" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi rm -rf "$CURL_DIR" &>/dev/null tar -xzf "$CURL_TAR" cd "$CURL_DIR" CPPFLAGS="-I$INSTALL_ROOT/include" LDFLAGS="-Wl,-rpath,$INSTALL_LIB64 -L$INSTALL_LIB64" \ LIBS="-lidn2 -lssl -lcrypto -lz -ldl -lpthread" \ ./configure --enable-shared --with-ssl="$INSTALL_ROOT" --with-libidn2="$INSTALL_ROOT" --libdir="$INSTALL_LIB64" if [[ "$?" -ne "0" ]]; then echo "Failed to configure cURL" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi make -j 4 if [ "$?" -ne "0" ]; then echo "Failed to build cURL" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi echo "$SUDO_PASSWWORD" | sudo -S make install cd .. ############################################################################### echo echo "********** Git **********" wget "https://github.com/git/git/archive/$GIT_TAR" -O "$GIT_TAR" if [[ "$?" -ne "0" ]]; then echo "Failed to download Git" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi rm -rf "$GIT_DIR" &>/dev/null tar -xzf "$GIT_TAR" cd "$GIT_DIR" make configure CPPFLAGS="-I$INSTALL_ROOT/include" LDFLAGS="-Wl,-rpath,$INSTALL_LIB64,-rpath,$INSTALL_LIB32 -L$INSTALL_LIB64 -L$INSTALL_LIB32" \ LIBS="-lidn2 -lssl -lcrypto -lz -ldl -lpthread" ./configure --with-openssl --with-curl --with-libpcre --prefix="$INSTALL_ROOT" if [[ "$?" -ne "0" ]]; then echo "Failed to configure Git" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi make all -j 4 if [ "$?" -ne "0" ]; then echo "Failed to build Git" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi MAKE=make MAKE_FLAGS=(install) if [[ ! -z `which asciidoc 2>/dev/null | grep -v 'no asciidoc'` ]]; then if [[ ! -z `which xmlto 2>/dev/null | grep -v 'no xmlto'` ]]; then MAKE_FLAGS+=("install-doc" "install-html" "install-info") fi fi echo "$SUDO_PASSWWORD" | sudo -S "$MAKE" "${MAKE_FLAGS[@]}" cd .. ############################################################################### echo echo "********** Cleanup **********" rm -rf "$OPENSSL_TAR $OPENSSL_DIR $UNISTR_TAR $UNISTR_DIR $CURL_TAR $CURL_DIR" rm -rf "$PCRE_TAR $PCRE_DIR $ZLIB_TAR $ZLIB_DIR $IDN2_TAR $IDN2_DIR $GIT_TAR $GIT_DIR" [[ "##代码##" = "$BASH_SOURCE" ]] && exit 0 || return 0

回答by GrandmasterB

Just updating this for 2017 and later, as CentOS 5 has reached EOL and the URL for EPEL has changed:

由于 CentOS 5 已达到 EOL 并且 EPEL 的 URL 已更改,因此仅针对 2017 年及以后更新此内容:

##代码##

This gets you git 1.8.2.3

这让你 git 1.8.2.3