1,环境
Centos7 & jdk8
2,部署步骤
[root@localhost ~]# yum -y install epel-release git
[root@localhost ~]# yum -y install curl openssh-server openssh-clients postfix cronie policycoreutils-python
[root@localhost ~]# systemctl restart postfix
[root@localhost ~]# systemctl enable postfix
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm
[root@localhost src]# rpm -ivh gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm #此处时间较长请耐心等待
[root@localhost src]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.1.60' //将此处设为gitlab的服务器ip地址亦或域名
[root@localhost ~]# gitlab-ctl reconfigure //重载配置文件并重启gitlab
[root@localhost ~]# gitlab-ctl restar
[root@localhost ~]# head -1 /opt/gitlab/version-manifest.txt //查看当前的gitlab版本
gitlab-ce 11.2.1
[root@localhost ~]# gitlab-rails console production
-------------------------------------------------------------------------------------
GitLab: 11.2.1 (2d6c1c6)
GitLab Shell: 8.1.1
postgresql: 9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password = '设置密码'
=> "设置密码"
irb(main):003:0> user.save!
=> true
irb(main):004:0> exit
3,访问gitlab :ip + port
默认nginx端口为80,避免端口被占用,你可以修改自己的端口,记得防火墙要开放端口。
开放端口:
## 开放防火墙
firewall-cmd --list-ports #查看端口
firewall-cmd --zone=public --add-port=8003/tcp --permanent #添加端口
firewall-cmd --reload #加载
修改端口:
cd /var/opt/gitlab/nginx/conf
vim gitlab-http.conf
---- site configuration(截取一部分) ----
upstream gitlab-workhorse {
server unix:/var/opt/gitlab/gitlab-workhorse/socket;
}
server {
listen *:80; --修改端口
server_name localhost;
server_tokens off; ## Don't show the nginx version number, a security best practice
重启网关:
gitlab-ctl restart
查看服务:
ps -ef | grep gitlab
4,进入gitlab服务web页,进行配置,参考下面链接
web页配置gitlab链接