- 这是我用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
-
- 在线下载安装包: