阿里云centos7 安装gitlab

1.先安装相关依赖

yum -y install policycoreutils openssh-server openssh-clients postfix

 2、启动postfix,并设置为开机启动

目的:支持gitlab邮件发送  

systemctl start postfix
Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.
systemctl enable postfix

3.下载并安装Gitlab社区版RPM包

我的下载路径如下:

https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-10.5.2-ce.0.el7.x86_64.rpm

gitlab-ce-10.5.2-ce.0.el7.x86_64.rpm 
注意根据自己的linux系统选择合适的包 

wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-10.5.2-ce.0.el7.x86_64.rpm/download.rpm
再输入:rpm -ivh gitlab-ce-10.5.2-ce.0.el7.x86_64.rpm 安装完毕

阿里云centos7 安装gitlab

如果报错,就执行

yum install policycoreutils-python


然后在安装

rpm -ivh gitlab-ce-10.5.2-ce.0.el7.x86_64.rpm

下图代表安装完毕。

阿里云centos7 安装gitlab

4.修改gitlab配置文件指定服务器ip和自定义端口:

vim  /etc/gitlab/gitlab.rb

阿里云centos7 安装gitlab

注意这里设置的端口不能被占用,默认是8080端口,如果8080已经使用,请自定义其它端口,并在防火墙设置开放相对应得端口

5.重置并启动Gitlab

重置:gitlab-ctl reconfigure

注:第一次预计需要几分钟

阿里云centos7 安装gitlab

gitlab-ctl restart

提示  "ok: run:"表示启动成功

阿里云centos7 安装gitlab

6.浏览器访问Gitlab

直接通过域名端口访问:http://ip:port

如果没有域名,直接输入服务器ip和指定端口进行访问

初始账户: root 密码:5iveL!fe

第一次登录修改密码

阿里云centos7 安装gitlab

 

二、在Gitlab里配置项目

1.配置Gitlab用户邮箱

User Settings - Emails 中添加邮箱并confirm

可以创建一个新的

2.添加开发电脑的key到Gitlab上

先确保你的开发电脑上已安装Git,并做好基本准备,这个不再多说 
打开Git Bash生成key: 
在bash中输入ssh-****** -t rsa -C “[email protected] 即可,后面输入自己的邮箱 

然后一路回车,使用默认值即可,由于这个Key也不是用于军事目的,所以也无需设置密码。

如果一切顺利的话,可以在用户主目录里找到.ssh目录,里面有id_rsaid_rsa.pub两个文件,这两个就是SSH Key的秘钥对,id_rsa是私钥,不能泄露出去,id_rsa.pub是公钥,可以放心地告诉任何人。

第2步:登陆GitHub,打开“Account settings”,“SSH Keys”页面:

然后,点“Add SSH Key”,填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容:

阿里云centos7 安装gitlab
 
阿里云centos7 安装gitlab

 

3.将开发电脑上已存在的项目导入到Gitlab上

先在Gitlab上创建一个空项目-test 
阿里云centos7 安装gitlab

再打开本地Git Bash,配置全局的 user.name 和 user.email:

 
  1. git config --global user.name "root"

  2. git config --global user.email "[email protected]"

  • 1
  • 2

首先cd到你需要导入的项目目录下,再执行导入命令:

 
  1. git init

  2. git remote add origin [email protected]:root/test.git

  3. git add .

  4. git commit -m "测试-test"

  5. git push -u origin master

至此,可以到浏览器刷新test项目,发现导入成功