gitlab安装配置及使用

1、安装配置依赖项:

[root@sunan ~]# yum install curl openssh-server openssh-clients postfix policycoreutils policycoreutils-python -y

2、启动postfix,并设置开机自启,postfix支持gitlab发信功能

[root@sunan ~]# systemctl start postfix
[root@sunan ~]# systemctl enable postfix

3、下载gitlab并安装:
centos 7系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
下载:

[root@sunan ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.8.7-ce.0.el7.x86_64.rpm

安装:

[root@sunan software]# rpm -ivh gitlab-ce-12.8.7-ce.0.el7.x86_64.rpm 

4、修改配置文件:

[root@sunan software]# vim /etc/gitlab/gitlab.rb
#修改服务器ip和端口号,例如:http://121.36.210.10:80
external_url 'http://gitlab.example.com'

5、读取配置文件并启动gitlab:

[root@sunan software]# gitlab-ctl reconfigure

gitlab-ctl start|stop|status|restart
6、浏览器访问gitlab页面:
使用配置文件中设置的external_url访问即可,初次访问需要修改密码。
gitlab安装配置及使用

7、配置gitlab的SSH keys:
window版本下载git使用git的Bash即可,下载git地址为https://github.com/git-for-windows/git/releases/download/v2.25.1.windows.1/Git-2.25.1-64-bit.exe ,安装时直接下一步即可,然后window桌面右击选择Git Bash Here即可打开git bash。

sunan@LAPTOP-DURKEJLQ MINGW64 /d/key
$ ssh-keygen -t ed25519 -C "[email protected]"

上面的邮箱请替换为自己的邮箱。
生成的key值为此文件C:\Users\sunan.ssh\id_ed25519.pub,使用记事本打开将其中的内容复制出来。
8、打开gitlab配置ssh即可:
gitlab安装配置及使用

9、测试是否配置成功,打开Git Bash:

sunan@LAPTOP-DURKEJLQ MINGW64 /d/key
$ ssh.exe -T [email protected]
The authenticity of host '121.36.210.xx (121.36.210.xx)' can't be established.
ECDSA key fingerprint is SHA256:KiSERpBsNld6Z440I5bRQgeISMAUXCSd35fLC4MQxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '121.36.210.xx' (ECDSA) to the list of known hosts.
Connection closed by 121.36.210.xx port 22

以上显示测试连接成功。

猜你喜欢

转载自blog.51cto.com/13486869/2480831