Linux下GitLab的安裝部署
Gitlab官網(wǎng):https://about.gitlab.com/installation/#centos-7
1由捎、安裝和配置必要的依賴項(xiàng)淮阐。
在CentOS上,以下命令也將在系統(tǒng)防火墻中打開(kāi)HTTP和SSH訪問(wèn)。
sudo yum install curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
2、添加GitLab倉(cāng)庫(kù),并安裝到服務(wù)器上
- 方法一
推薦
:
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo yum install gitlab-ce
- 方法二: 手動(dòng)下載文件,然后使用rpm命令安裝
curl -LJO https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-XXX.rpm/download
rpm -i gitlab-ce-XXX.rpm
3病袄、啟動(dòng)GitLab
sudo gitlab-ctl reconfigure
4搂赋、打開(kāi)瀏覽器訪問(wèn)赘阀,默認(rèn)80端口
- 首次訪問(wèn)需要設(shè)置root密碼
- 關(guān)閉注冊(cè)功能
Admin Area > Settings >Sign-up Restrictions
取消Sign-up enabled
勾選
5、常用配置不建議修改
- 修改內(nèi)置nginx端口號(hào)脑奠,默認(rèn)是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'
每次重新配置宋欺,都需要執(zhí)行sudo gitlab-ctl reconfigure
使之生效轰豆。
6胰伍、日常管理
- 常用命令
gitlab-ctl start|stop|status|restart
比如查看狀態(tài):
[root@iZ234865htyZ ~]# gitlab-ctl status
run: gitaly: (pid 12614) 97739s; run: log: (pid 3429) 159390s
run: gitlab-monitor: (pid 12622) 97738s; run: log: (pid 3610) 159368s
run: gitlab-workhorse: (pid 12625) 97738s; run: log: (pid 3443) 159384s
run: logrotate: (pid 947) 446s; run: log: (pid 3474) 159382s
run: nginx: (pid 14129) 97293s; run: log: (pid 2415) 103679s
run: node-exporter: (pid 12648) 97737s; run: log: (pid 3509) 159378s
run: postgres-exporter: (pid 12654) 97736s; run: log: (pid 3559) 159370s
run: postgresql: (pid 12660) 97736s; run: log: (pid 3262) 159439s
run: prometheus: (pid 12668) 97735s; run: log: (pid 3491) 159380s
run: redis: (pid 12678) 97735s; run: log: (pid 2829) 159471s
run: redis-exporter: (pid 12682) 97735s; run: log: (pid 3525) 159372s
run: sidekiq: (pid 9931) 14072s; run: log: (pid 3415) 159392s
run: unicorn: (pid 14261) 97263s; run: log: (pid 3380) 159393s
- 查看日志
/var/log/gitlab
可以進(jìn)去查看訪問(wèn)日志以及報(bào)錯(cuò)日志
gitlab-ctl tail #查看所有日志
gitlab-ctl tail nginx/gitlab_access.log #查看nginx訪問(wèn)日志
7、卸載GitLab
停止gitlab酸休,執(zhí)行
sudo gitlab-ctl stop
卸載gitlab骂租,執(zhí)行sudo rpm -e gitlab-ce
查看gitlab進(jìn)程,殺掉第一個(gè)守護(hù)進(jìn)程kill -9 pid
刪除gitlab文件斑司,執(zhí)行find / -name gitlab|xargs rm -rf
刪除所有包含gitlab的文件及目錄渗饮,
再執(zhí)行gitlab-ctl uninstall
刪除自動(dòng)在root下備份的配置文件。