频道栏目
首页 > 资讯 > 其他综合 > 正文

Gitlab搭建git代码托管服务器

17-09-05        来源:[db:作者]  
收藏   我要投稿

一. 安装git

如果是Ubuntu的环境,执行以下命令安装

安装:
    sudo apt-get install git
配置git用户名和邮箱:
    git config --global user.name "your_name"
    git config --global user.email "your_email"

如果是centos的环境,执行以下命令安装

    yum install git

二.生成ssh密钥(没有ssh服务请先开启)

执行命令:

    ssh-keygen -t rsa -C "yourEmail"
    一路回车,全部采用默认的方式

生成的密钥位于~/.ssh目录下的id_rsa.pub文件

三.在服务器主机上添加git用户

执行以下命令:

    添加:adduser git
    修改用户密码:pwd git
    禁用git用户shell登录:修改/etc/passwd文件将:git:x:1000:1000::/home/git:/bin/bash
        修改为:git:x:1000:1000::/home/git:/usr/bin/git-shell

四.安装并配置gitlab

这里贴上centos7的安装配置教程,Ubuntu系统参考官网教程,官网提供了各系统的相关配置教程Gitlab

1. 安装必要的配置和依赖
sudo yum install curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd –permanent –add-service=http
sudo systemtl reload firewalld
以上过程中,开启postifix服务可能会遇到:
Job for postfix.service failed because the control process exited with error code. See “systemctl status postfix.service” and “journalctl -xe” for details.
修改/etc/postfix/main.cf文件:
inet_protocols = ipv4
inet_interfaces = all
如果firewalld 未开启执行sudo systemctl start firewalld开启防火墙

2. 添加Gitlab软件包服务器和安装程序包
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
yum install gitlab-ce
3.启动gitlab
sudo yum install gitlab-ce
打开浏览器,访问你的服务器地址即可进入gitlab
4.修改gitlab默认的端口,防止和tomcat以及80端口发生冲突
修改/etc/gitlab/gitlab.rb文件:
external_url 值为’yourURL:9999’
unicorn[‘port’] = 8091
重启gitlab以生效:sudo yum install gitlab-ce

五.成功图:

这里写图片描述

相关TAG标签
上一篇:Perl 入门实战:JVM 监控脚本(下)
下一篇:linux常用命令
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站