Centos7配置ip并安装GitLab

本文详细介绍了如何在虚拟机上配置静态IP地址,确保其与宿主机互联并访问互联网,随后逐步指导安装GitLab,包括依赖安装、服务配置、防火墙设置及GitLab包的下载与安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 这是我用VMware新创建的一台虚拟机,首先要做的是配置虚拟机ip,使之能与宿主机互联并且能访问外网。
    • 新建的虚拟机一般是不分配IP,而且IP也为动态IP,做如下修改:
    • vi /etc/sysconfig/network-scripts/ifcfg-ens33
      #修改成如下:
      
      BOOTPROTO=static #修改
      ONBOOT=yes       #修改
      
      #添加
      IPADDR=192.168.248.100 #确定网段的情况下 给了 100 
      NETMASK=255.255.255.0  #都是一样的
      GATEWAY=192.168.248.2  #下张图片教你们在哪找
      DNS1=114.114.114.114   # 这俩域名解析
      DNS2=8.8.8.8

    • 编辑 -> 虚拟网络编辑器 -> vmnet8 -> NAT设置

    • #重启网卡
      
      systemctl restart network

       

    • ping 宿主机IP, ping www.baidu.com , 宿主机ping 192.168.248.100 三者皆通 开始 安装 GitLab


安装GitLab之前说明,如果服务器只有2G的内存,比如阿里云最低配置的服务器,就别装了,直接卡死,然后远程登陆还登不上了,Cpu直接拉满。这里我虚拟机分配的内存为8G,运行正常

  • 安装相关依赖

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

       

  • 启动ssh服务&设置为开机启动

    • systemctl enable sshd && sudo systemctl start sshd 

       

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

    • systemctl enable postfix && 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.

      解决方案:

    • #修改 /etc/postfix/main.cf 的设置
      inet_protocols = ipv4
      inet_interfaces = all
      
      #再次开启
      systemctl start postfix

       

  • 开放ssh以及http服务,然后重新加载防火墙列表

    • firewall-cmd --add-service=ssh --permanent 
      firewall-cmd --add-service=http --permanent 
      firewall-cmd --reload

      出现问题:

    • FirewallD is not running

      解决方案:

    • systemctl start firewalld
      #再执行以下命令
      firewall-cmd --add-service=ssh --permanent 
      firewall-cmd --add-service=http --permanent 
      firewall-cmd --reload

       

  • 下载gitlab包,并且安装

    • 在线下载安装包:
      • wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm

         

    • 安装 :

      • rpm -i gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm

        出现问题:

      • error: Failed dependencies:
                policycoreutils-python is needed by gitlab-ce-12.4.2-ce.0.el6.x86_64

        解决方案:

      • yum install policycoreutils-python -y
        
        #完成后
        
        rpm -i gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm

         

    • 修改GitLab配置

      • vi /etc/gitlab/gitlab.rb
        
        external_url 'http://服务器ip:8088'
        nginx['listen_port'] = 8088

         

    • 重载配置及启动gitlab

      • 重载配置:

      • gitlab-ctl reconfigure

        这个地方如果卡了很久,说明机器CPU拉满了,建议换个CPU更大的服务器

      • 启动GitLab

      • gitlab-ctl restart

         

    • 把端口添加到防火墙
      • firewall-cmd --zone=public --add-port=8088/tcp --permanent
        firewall-cmd --reload

        以上操作完成:登录 http://服务器ip:8088 访问GitLab

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值