1.安装配置必须的依赖

yum install curl policycoreutils openssh-server openssh-clients

systemctl enable sshd

systemctl start sshd

yum install postfix

systemctl enable postfix

systemctl start postfix

firewall-cmd --permanent --add-service=http

systemctl reload firewalld

2.安装gitlab

rpm -ivh gitlab-ce-8.11.6-ce.0.el6.x86_64.rpm

3.配置并启动gitlab

gitlab-ctl reconfigure

4.默认账户密码

Username: root

Password: 5iveL!fe

5.备份

gitlab-rake gitlab:backup:create

默然的备份目录为: /var/opt/gitlab/backups 


修改备份目录


vi /etc/gitlab/gitlab.rb

gitlab_rails['backup_path'] = '/mnt/gitlab_backups'


6.数据恢复和还原

     

  停止服务

gitlab-ctl stop unicorn

gitlab-ctl stop sidekiq


BACKUP后面跟的是备份文件的时间戳,比如恢复备份文件1458217074_gitlab_backup.tar,注:需要恢复的文件必须放在gitlib的备份目录下

gitlab-rake gitlab:backup:restore BACKUP=1458213020


恢复完成启动服务


gitlab-ctl start/restart


以上gitlab基本搭建完成 网页直接IP访问 默认端口为80 

#修改默认端口

1.Change port to 81 (You can choose your own) at port: near by production:$base >> gitlab: for file /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml


2.Change your host address if you like to use different from your ip address or localhost


3.Change server port to 81 in file "/opt/gitlab/embedded/conf/nginx.conf"


4.Restart gitlab using command "sudo gitlab-ctl restart".


5.Open "/etc/gitlab/gitlab.rb" to text editor where currently I have external_url 'http://myipaddress/' as text. I just change to

external_url 'http://gitlab.com.local:81/'

then reconfigure using command "sudo gitlab-ctl reconfigure" and voila, Gitlab is now working on port 81.


#开机自启动

systemctl enable gitlab-runsvdir.service

systemctl start gitlab-runsvdir.service

gitlab-cmd start