centos7搭建gitlab

系统:centos 7 64位

主要工作

安装时,最好切换到root用户。许多操作都需要root权限。

1、安装ssh
用于远程登录
2、安装postfix
用于发送邮件
3、安装gitlab
创建本地的git服务器

使用的工具:
yum :安装软件的工具,可以进行在线安装。下载速度慢的话,因该是源的问题,建议更新到国内的镜像源。
wget: 当yum源中没有相应的软件时,可以使用wget下载软件的安装包进行本地安装。
rpm: 安装rpm格式软件包的工具。

还需要介绍,centos7 的防火墙(firewalld),防火墙配置工具(firewall-cmd)
当centos的防火墙开启时,centos同外界的数据传输受到firewalld的管理。firewalld默认不开启任何端口,如果想在外部访问centos上的服务,需要在防火墙中开放服务运行的端口,并重新加载防火墙。

从外部访问centos时使用的时浏览器,所以要在防火墙中添加http和https服务,允许http和https访问。
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https

1、安装ssh (这个工具系统中一般都会有,安装之前先ssh验证一下)
yum search ssh #在yum源中查询相关的软件

if:返回结果中包含openssh-server.x86_64 : An open source SSH server daemon
执行,yum -y install openssh-server.x86_64 进行在线安装。
安装完成后,输入ssh查看,ssh是否正确安装。

else:cd /usr/local/src,ssh默认安装在/usr/local/src文件夹下,wget现在资源时,会将资源存放在当前目录下。
下载安装包:wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.0p1.tar.gz
解压 tar -zxvf <安装包>
然后 make install
即可安装完成

输入ssh命令验证。

ssh配置文件:/etc/ssh/sshd_config
ssh开机启动:systemctl enable sshd
开启ssh服务:sudo service sshd start或者systemctl start sshd
关闭ssh服务:sudo service sshd stop或者systemctl stop sshd
重启ssh服务:sudo service sshd restart或者systemctl restart sshd

2、安装postfix
yum search postfix

if:结果中包含postfix.x86_64 : Postfix Mail Transport Agent
yum install postfix.x86_64
完成后输入postfix查看。

else:下载安装包,wget http://cdn.postfix.johnriley.me/mirrors/postfix-release/official/postfix-3.0.11.tar.gz
解压并进入解压后的文件夹,执行命令:make&make install
完成后输入postfix验证

配置文件:/etc/postfix/main.cf
postfix开机启动:systemctl enable postfix
开启postfix:service postfix start或者systemctl start postfix

3、安装gitlab
yum search gitlab

if:结果包含gitlab-ee.x86_64 : GitLab Enterprise Edition (including NGINX, Postgres, Redis)
yum install gitlab-ee.x86_64

else:下载wget wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
安装:rpm -ivh <安装包>

安装完成后需要修改配置文件,实现外部访问
vi /etc/gitlab/gitlab.rb打开配置文件,
1、修改external_url ‘http://<你的域名>.com’ ,该域名只能在本地使用,想要在公网使用该域名需要购买,还是用IP吧。
2、修改unicorm[‘listen’] = ‘0.0.0.0’ #监听所有IP
3、修改nuicorn[‘port’] = 8010,我是用801开头的端口来命名gitlab使用的端口。方便管理。
保存退出

使修改后的配置生效:gitlab-ctl reconfigure
开启gitlab:gitlab-ctl start

现在外部还不能访问,因为防火墙没有开放8010端口
开放端口: 查看开放的端口:firewall-cmd --zone= public --list-ports
开放8010端口:firewall-cmd --zone=public --add-port=8010/tcp --permanent #–permanent永久生效
重启防火墙:firewall-cmd --reload #修改生效

此时在浏览器中输入,http://ip:8010就会来到gitlab的页面。第一次登录需要设置管理员账户。然后就可以像github一样使用了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值