美文网首页
[1]CentOS7+gitlab搭建虚拟机代码仓库

[1]CentOS7+gitlab搭建虚拟机代码仓库

作者: 金属勺子 | 来源:发表于2019-10-31 13:06 被阅读0次

    环境要求

    • 主机安装git
    • CentOS7系统下载:清大开源或者其他国内开源镜像站
    • VmWare或者其他方式安装虚拟机
    • 虚拟机内存配置4G最佳,低于4G可能无法正常进入gitlab页面

    安装过程

    • 官网提供了企业版安装方法,社区版安装方式类似,下面贴上社区版安装步骤
    • 前面和企业版一样启动配置,安装必要依赖
    sudo systemctl enable sshd
    sudo systemctl start sshd
    sudo firewall-cmd --permanent --add-service=http
    sudo firewall-cmd --permanent --add-service=https
    sudo systemctl reload firewalld
    
    • 安装Postfix
    sudo systemctl enable postfix
    sudo systemctl start postfix
    
    • 添加镜像这一步,选择ce版
    curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
    sudo EXTERNAL_URL="http://gitlab.my.com" yum -y install gitlab-ce
    
    • 一般都可以正常安装完成。
    • 然后就可以通过浏览器访问了,http://ip,ip通过ifconfig查看。

    完成配置

    • 安装好以后,当然需要实际使用,下面列出配置步骤。
    • 第一次进入时默认以root方式登录,提示更改密码,视个人需要选择创建新用户或者直接用root来配置,进入Gitlab界面后在Settings - Emails选项中配置邮箱
    • 然后,在主机上(我的是Win10)执行
    ssh-keygen -t rsa -C “email@example.com”
    

    email@example.com填写自己配置的邮箱

    • 复制.ssh/下面的id_rsa.pub中的内容,将它粘贴到Settings - SSH Keys空白处,add key。
    • gitlab中创建一个新的项目test
    • 在主机上,使用git bash,依照个人情况执行
    git config --global user.name "user"
    git config --global user.email "email@example.com"
    
    • 然后进入到自己开发目录下,执行
    git init
    git remote add origin git@ip/user/test.git
    git add .
    git commit -m "test"
    git push -u origin master
    
    • 成功完成这一步,就可以在浏览器刷新出项目了

    修改映射

    • 修改主机C:\Windows\System32\drivers\etc\hosts文件,需要获取权限
      添加ip git.**自己的映射,主机即可使用配置的名称替代ip了
    • 虚拟机中在/etc/hosts下面添加映射
    127.0.0.1  git.**
    

    相关文章

      网友评论

          本文标题:[1]CentOS7+gitlab搭建虚拟机代码仓库

          本文链接:https://www.haomeiwen.com/subject/fezzvctx.html