云服务器gitlab的搭建(Centos7)

step1:注册(注册免费版即可)

gitlab注册入口:https://gitlab.com/users/sign_in 

(此步骤可跳过)gitlab官网搭建步骤(centos7):https://about.gitlab.com/install/#centos7

step2:安装和配置依赖(必需)

官方centos7配置链接:https://about.gitlab.com/installation/#centos-7

(1)安装软件

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd

(2)防火墙设置

sudo firewall-cmd --permanent --add-service=http

sudo systemctl reload firewalld

(3)安装postfix发送通知邮件(可跳过)

sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

(4)添加gitlab库及安装包(gitlab-ce社区版)

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

(5)安装gitlab包

sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ce

sudo gitlab-ctl reconfigure [自动配置文件权限,安装数据库(安装的时间很长)]

sudo gitlab-ctl restart (修改之后,一定要自动配置,并重启,不可缺少)

注意:"http://gitlab.example.com"此处需要修改成自己的云服务器的域名或者修改成云服务器的公网ip,如"http://156.1.1.2"

注意2:vim /etc/gitlab/gitlab.rb (EXTERNAL_URL也可在文件/etc/gitlab/gitlab.rb中修改,本条命令是指找到文件并打开)

如下图所示:

step3访问

gitlab在服务器上默认端口为80,访问时直接在浏览器中输入修改的EXTERNAL_URL,例如http://159.1.1.2:80

访问是先出现的是确认密码的页面,确认好密码之后就可以signin了,账号:root密码:第一次设置的密码

注意:若以上访问不成功,别慌,看下面

公然访问公网,或许遇到端口不可见的情况,因此访问不成功。要用到SSH隧道技术和端口转发了。

打开自己的pc电脑上可访问服务器的窗口,若是windows可以安装gitbash或者xshell,如是linux可以直接打开终端了。

输入命令:ssh -N -f -L <port2>:<ip1>:<port1> <username>@<ip>

port2:指你映射到本地的端口

ip1:可输入127.0.0.1

port1:指服务器上gitlab占用的端口了80(若修改了需要填写修改之后的)

username:服务器上的用户名

ip:服务器的公网IP

访问时再来浏览器输入"http://127.0.0.1:port2"就可以啦,上图:

step4端口的修改(个人喜好啦)

cd /var/opt/gitlab/nginx/conf

vim gitlab-http.conf

上图:

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值