首页 > 技术文章 > 虚拟机安装centos7, 再安装gitlab 简单步骤

-yun 2017-07-03 18:52 原文

 

先安装Linux centos7(朋友贡献的. Linux官网有下)

我自己用vm安装的. 未出现特殊状况

 

gitlab的搭建

  • 安装基础包
yum -y install curl policycoreutils openssh-server openssh-clients
  • 启动sshd
 systemctl enable sshd
 systemctl start sshd
这里没有任何反馈
  • 安装postfix
yum -y install postfix
systemctl enable postfix
systemctl start postfix

这里没有任何反馈
  • 添加防火墙规则
firewall-cmd --permanent --add-service=http
systemctl reload firewalld
  • 下载并安装软件包(软件包下载较慢)
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
yum install gitlab-ce

默认安装的是最新的gitlab-ce的包,如果需要特定的版本可以在官网去下载特定的版本 
地址:

https://packages.gitlab.com/gitlab/gitlab-ce/
  • 配置并启动gitlab
 gitlab-ctl reconfigure


最后一步,比如你服务器ip地址是192.168.100.101  浏览器就访问这个ip地址,就出现gitlab站点了,输入帐号密码登录
  • 默认账户密码是
Username: root 
Password: 密码在第一次进入会要求你change



虚拟机Linux映射到本地IP

先  

 # vim /etc/sysconfig/network-scripts/ifcfg-eth0

再   

BOOTPROTO="static" #dhcp改为static     这个是改静态用的.实际不改. 自己记录用 

ONBOOT="yes" #开机启用本配置      改这里就OK

IPADDR=192.168.7.106 #静态IP  

GATEWAY=192.168.7.1 #默认网关  

NETMASK=255.255.255.0 #子网掩码



给虚拟机nat网卡开启端口映射

在VMware Player中,并不像VMware Station中提供网络编辑功能,因此如果想使用port forward功能,则需要进行手动配置.

例如在Windows xp操作系统中,找到vmware nat的配置文件:

C:\Documents and Settings\All Users\Application Data\VMware\vmnetnat.conf

在windows 7系统中,vmware nat的配置文件在:

C:\ProgramData\VMware\vmnetnat.conf

如果想使用TCP,则修改其[incomingtcp]下面的配置选项,如:

8888 = 192.168.20.56:80

其意思是将主机的8888端口映射到虚拟机的80端口,这样其它的机器只要访问这台主机的8888端口,就可以访问到其虚拟机的80端口了

比如我的是增加了一下几项:

22:192.168.20.56:22  (ssh端口)

80:192.168.20.56:80   (将虚拟机的80端口映射到主机的80端口,这样的话,主机上不能再使用80端口)

 

最后需要在主机上重新启动一下vmware NAT service服务,然后就可以正常访问了.

服务的查看方法,在cmd中执行:

sc query|find /i "vmware"

执行后发现有如下服务名:

DISPLAY_NAME: VMware Authorization Service

DISPLAY_NAME: VMware DHCP Service

DISPLAY_NAME: VMware USB Arbitration Service

SERVICE_NAME: VMware NAT Service

DISPLAY_NAME: VMware NAT Service

在cmd中使用net stop "VMware NAT Service"&net start "VMware NAT Service"命令可以重启服务。

注:如果访问不了,请查看Windows防火墙是否阻止了这些端口.

另外,可以在本地机器设置一个host,这样可以使用域名的方式登录自己的虚拟机,或者查看虚拟机上的网站。

比如在windows下可以设置C:\Windows\System32\drivers\etc\hosts文件,在其中增加:

127.0.0.1   saiwaike.org

那样就可以使用saiwaike.org访问虚拟机中的网站了。



推荐阅读