Linux Centos7下安装GitLab最详细教程

来源:互联网 发布:c语言什么时候用void 编辑:程序博客网 时间:2024/05/19 16:06

Linux下GitLab的安装部署

Gitlab官网:https://about.gitlab.com/installation/#centos-7

1、安装和配置必要的依赖项。

在CentOS上,以下命令也将在系统防火墙中打开HTTP和SSH访问。

sudo yum install curl policycoreutils openssh-server openssh-clientssudo systemctl enable sshdsudo systemctl start sshdsudo yum install postfixsudo systemctl enable postfixsudo systemctl start postfixsudo firewall-cmd --permanent --add-service=httpsudo systemctl reload firewalld

2、添加GitLab仓库,并安装到服务器上

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bashsudo yum install gitlab-ce

手动下载文件,然后使用rpm命令安装

curl -LJO https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-XXX.rpm/downloadrpm -i gitlab-ce-XXX.rpm

3、启动GitLab

sudo gitlab-ctl reconfigure

4、打开浏览器访问,默认80端口

你第一次的访问,需要设置初始管理员帐户的密码。默认的帐户的用户名是root。

这里写图片描述

关闭注册功能 Admin Area > Settings >Sign-up Restrictions

这里写图片描述

5、常用配置

  • 修改内置nginx端口号,默认是80,修改 vim var/opt/gitlab/nginx/conf/gitlab-http.conf
 server {  listen *:8222;  ......
  • gitlab本身采用80端口,配置GitLab的URL,修改 vim /etc/gitlab/gitlab.rb
external_url 'http://127.0.0.1:8222'

每次重新配置,都需要执行sudo gitlab-ctl reconfigure 使之生效。

6、日常管理

  • 常用命令gitlab-ctl start|stop|status|restart 比如查看状态:
[root@iZ234865htyZ ~]# gitlab-ctl statusrun: gitaly: (pid 12614) 97739s; run: log: (pid 3429) 159390srun: gitlab-monitor: (pid 12622) 97738s; run: log: (pid 3610) 159368srun: gitlab-workhorse: (pid 12625) 97738s; run: log: (pid 3443) 159384srun: logrotate: (pid 947) 446s; run: log: (pid 3474) 159382srun: nginx: (pid 14129) 97293s; run: log: (pid 2415) 103679srun: node-exporter: (pid 12648) 97737s; run: log: (pid 3509) 159378srun: postgres-exporter: (pid 12654) 97736s; run: log: (pid 3559) 159370srun: postgresql: (pid 12660) 97736s; run: log: (pid 3262) 159439srun: prometheus: (pid 12668) 97735s; run: log: (pid 3491) 159380srun: redis: (pid 12678) 97735s; run: log: (pid 2829) 159471srun: redis-exporter: (pid 12682) 97735s; run: log: (pid 3525) 159372srun: sidekiq: (pid 9931) 14072s; run: log: (pid 3415) 159392srun: unicorn: (pid 14261) 97263s; run: log: (pid 3380) 159393s
  • 查看日志 /var/log/gitlab 可以进去查看访问日志以及报错日志等。
gitlab-ctl tail #查看所有日志gitlab-ctl tail nginx/gitlab_access.log #查看nginx访问日志

6、卸载GitLab

通过以下几步就可以彻底卸载gitlab

  1. 停止gitlab,执行sudo gitlab-ctl stop
  2. 卸载gitlab,执行sudo rpm -e gitlab-ce
  3. 查看gitlab进程,杀掉第一个守护进程kill -9 pid
  4. 删除gitlab文件,执行find / -name gitlab|xargs rm -rf删除所有包含gitlab的文件及目录,再执行gitlab-ctl uninstall删除自动在root下备份的配置文件。
原创粉丝点击