首页 开发工具 git linux 源码怎么安装git

linux 源码怎么安装git

Dec 01, 2021 pm 04:47 PM
git linux

linux源码安装git的方法:1、下载git源码上传至Linux服务器;2、登录目标机器,解压并安装;3、安装“gcc gcc-c++”;4、执行一下git的安装命令即可。

linux 源码怎么安装git

本文操作环境:linux5.9.8系统、git 2.9.5版、Dell G3电脑。

linux 源码怎么安装git?

Linux 安装git/源码安装:

Git 安装

这里就不记录Windows/Mac OS系统的了,直接下载对应的安装程序,按步骤安装即可。

Linux 安装

登陆https://git-scm.com/download/linux

源码安装

1. 下载源码

可以在另一台电脑中下载好源码,然后上传至Linux服务器

https://mirrors.edge.kernel.org/pub/software/scm/git/
登录后复制

找到对应的版本。

2. 上传至服务器

以git-2.9.5.tar.gz为例,将下载好的文件上传至服务器。

scp git-2.9.5.tar.gz  root@192.168.0.102:/home/tools
登录后复制

scp git-2.9.5.tar.gz 目标机器的用户@目标机器ip:目标机器路径

3. 解压并安装

登陆目标机器,解压并安装。/home/Git是指的安装目录

tar -zxvf git-manpages-2.9.5.tar.gz
cd git-2.9.5
[root@localhost git-2.9.5]# ./configure  --prefix=/home/Git
[root@localhost git-2.9.5]# make && make install
4. ./configure 报错
[root@localhost git-2.9.5]# ./configure  --prefix=/home/Git
configure: Setting lib to 'lib' (the default)
configure: Will try -pthread then -lpthread to enable POSIX Threads.
configure: CHECKS for site configuration
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/tools/git-2.9.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
登录后复制

我的linux服务器执行报错中看出,gcc,cc,cl.exe为no。gcc是Linux的c语言编译器,说明我的机器中没有安装这些编译器。

分别安装以下gcc,gcc-c++,安装成功之后在执行一下git的安装命令

[root@localhost git-2.9.5]# yum install gcc
[root@localhost git-2.9.5]# yum install gcc-c++
[root@localhost git-2.9.5]# ./configure  --prefix=/home/Git
登录后复制

5. make命令报错

[root@localhost git-2.9.5]# make && make install
    * new build flags
    CC credential-store.o
In file included from credential-store.c:1:0:
cache.h:40:18: 致命错误:zlib.h:没有那个文件或目录
 #include <zlib.h>
                  ^
登录后复制

编译中断。

make: *** [credential-store.o] 错误 1

缺少 zlib的头文件, 开发包没装。安装zlib

[root@localhost git-2.9.5]# yum install zlib
[root@localhost git-2.9.5]# yum install zlib-devel
[root@localhost git-2.9.5]# yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
[root@localhost git-2.9.5]# make && make install
登录后复制

若无报错则安装成功

6.检查git安装是否完成

进入之前指定的安装目录,查看git版本,能成功则表示git安装完成

[root@localhost bin]# cd /home/Git/bin
[root@localhost bin]# ./git --version
git version 2.9.5
登录后复制

7.配置环境变量

vi /etc/profile
登录后复制

编辑环境变量配置文件,在最后追加下面的字符串,指定bin目录的地址

export PATH=$PATH://home/Git/bin
登录后复制

修改完成之后,执行命令,生效配置文件

source /etc/profile
登录后复制

检查是否配置成功,可切换路径到其他目录中,执行 git --version。返回git版本则表示环境变量配置完成。

推荐学习:《Git教程

以上是linux 源码怎么安装git的详细内容。更多信息请关注PHP中文网其他相关文章!

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

linux怎么启动nginx linux怎么启动nginx Apr 14, 2025 pm 12:51 PM

在 Linux 中启动 Nginx 的步骤:检查 Nginx 是否已安装。使用 systemctl start nginx 启动 Nginx 服务。使用 systemctl enable nginx 启用在系统启动时自动启动 Nginx。使用 systemctl status nginx 验证启动是否成功。在 Web 浏览器中访问 http://localhost 查看默认欢迎页面。

nginx403错误怎么解决 nginx403错误怎么解决 Apr 14, 2025 pm 12:54 PM

服务器无权访问所请求的资源,导致 nginx 403 错误。解决方法包括:检查文件权限。检查 .htaccess 配置。检查 nginx 配置。配置 SELinux 权限。检查防火墙规则。排除其他原因,如浏览器问题、服务器故障或其他可能的错误。

怎么查看nginx是否启动 怎么查看nginx是否启动 Apr 14, 2025 pm 01:03 PM

确认 Nginx 是否启动的方法:1. 使用命令行:systemctl status nginx(Linux/Unix)、netstat -ano | findstr 80(Windows);2. 检查端口 80 是否开放;3. 查看系统日志中 Nginx 启动消息;4. 使用第三方工具,如 Nagios、Zabbix、Icinga。

怎么启动nginx服务器 怎么启动nginx服务器 Apr 14, 2025 pm 12:27 PM

启动 Nginx 服务器需要按照不同操作系统采取不同的步骤:Linux/Unix 系统:安装 Nginx 软件包(例如使用 apt-get 或 yum)。使用 systemctl 启动 Nginx 服务(例如 sudo systemctl start nginx)。Windows 系统:下载并安装 Windows 二进制文件。使用 nginx.exe 可执行文件启动 Nginx(例如 nginx.exe -c conf\nginx.conf)。无论使用哪种操作系统,您都可以通过访问服务器 IP

linux怎么查看nginx是否启动 linux怎么查看nginx是否启动 Apr 14, 2025 pm 12:48 PM

在 Linux 中,使用以下命令检查 Nginx 是否已启动:systemctl status nginx根据命令输出进行判断:如果显示 "Active: active (running)",则 Nginx 已启动。如果显示 "Active: inactive (dead)",则 Nginx 已停止。

nginx304错误怎么解决 nginx304错误怎么解决 Apr 14, 2025 pm 12:45 PM

问题的答案:304 Not Modified 错误表示浏览器已缓存客户端请求的最新资源版本。解决方案:1. 清除浏览器缓存;2. 禁用浏览器缓存;3. 配置 Nginx 允许客户端缓存;4. 检查文件权限;5. 检查文件哈希;6. 禁用 CDN 或反向代理缓存;7. 重启 Nginx。

nginx error日志怎么清理 nginx error日志怎么清理 Apr 14, 2025 pm 12:21 PM

错误日志位于 /var/log/nginx(Linux)或 /usr/local/var/log/nginx(macOS),使用命令行清理步骤:1. 备份原日志;2. 创建空文件作为新日志;3. 重启 Nginx 服务。也可使用第三方工具(如 logrotate)或配置自动清理。

centos和ubuntu的区别 centos和ubuntu的区别 Apr 14, 2025 pm 09:09 PM

CentOS 和 Ubuntu 的关键差异在于:起源(CentOS 源自 Red Hat,面向企业;Ubuntu 源自 Debian,面向个人)、包管理(CentOS 使用 yum,注重稳定;Ubuntu 使用 apt,更新频率高)、支持周期(CentOS 提供 10 年支持,Ubuntu 提供 5 年 LTS 支持)、社区支持(CentOS 侧重稳定,Ubuntu 提供广泛教程和文档)、用途(CentOS 偏向服务器,Ubuntu 适用于服务器和桌面),其他差异包括安装精简度(CentOS 精

See all articles