安装 git
从github的git项目中下载最新版本的git源码
git在github的发布页面:https://github.com/git/git/releases
在root用户下,执行以下命令,下载git安装包
1 | wget https://github.com/git/git/archive/v2.23.0.tar.gz |
[root@centos ~]# wget https://github.com/git/git/archive/v2.23.0.tar.gz
–2019-09-11 05:40:29– https://github.com/git/git/archive/v2.23.0.tar.gz
Resolving github.com (github.com)… 13.229.188.59
Connecting to github.com (github.com)|13.229.188.59|:443… connected.
HTTP request sent, awaiting response… 302 Found
Location: https://codeload.github.com/git/git/tar.gz/v2.23.0 [following]
–2019-09-11 05:40:30– https://codeload.github.com/git/git/tar.gz/v2.23.0
Resolving codeload.github.com (codeload.github.com)… 13.229.189.0
Connecting to codeload.github.com (codeload.github.com)|13.229.189.0|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘v2.23.0.tar.gz’
[ <=> ] 1,849,193 24.3KB/s
1 |
|
安装依赖包
1 | yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker |
编译 git 安装包
1 | make prefix=/usr/local/git all |
执行之后,会开始漫长的编译过程,直到控制台输出以下内容,说明编译已经成功完成了:
1 | GEN bin-wrappers/git |
安装Git至/usr/local/git,执行如下命令:
1 | make prefix=/usr/local/git install |
完成之后,输入以下命令,测试git 是否成功安装:
1 | git --version |
如果没有问题,则会输出当前安装的 git 的版本号:git version 1.8.3.1
配置环境变量
打开环境变量配置文件 /etc/profile, 在最后把 git 添加入 path 变量中。
1 | export PATH=$PATH:/usr/local/git/bin |
搭建git服务器
建立 git 用户
1 | useradd git -g oinstall -d /home/git |
配置用户公钥
收集所有需要登录的用户的公钥,就是他们自己的id_rsa.pub文件,把所有公钥导入到/home/git/.ssh/authorized_keys文件里,一行一
个。
如果文件不存在,手动创建一个。
1 | mkdir .ssh |
创建git创建
1 | git init --bare kayakwise.git |
创建 readme.md 说明
1 | touch readme.md |
使用
克隆仓库到本地
1 | git clone git@server:kayakwise.git |
这里我们通过使用包管理器这种最简单的方法来安装 Lighttpd。只需以 sudo 模式在终端或控制台中输入下面的指令即可。
git web
由于 CentOS 7.0 官方仓库中并没有提供 Lighttpd,所以我们需要在系统中安装额外的软件源 epel 仓库。使用下面的 yum 指令来安装 epel。
1 | yum install epel-release |
然后,我们需要更新系统及为 Lighttpd 的安装做前置准备。
1 | yum update |
参考:
Linux环境下搭建Git仓库
在 Linux 中安装 Lighttpd Web 服务器
环境部署(三):Linux下安装Git
搭建Git服务器
服务器上的 Git - GitWeb