部署自己的gitlib仓库
sudo apt-get install curl openssh-server ca-certificates postfix
curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
vim /etc/apt/sources.list.d/gitlab_gitlab-ce.list
添加清华源
deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial main
sudo apt-get update
sudo apt-get install gitlab-ce
sudo gitlab-ctl reconfigure
sudo gitlab-ctl status
# 结果
run: alertmanager: (pid 12427) 485s; run: log: (pid 19786) 16649s
run: gitaly: (pid 12440) 484s; run: log: (pid 19187) 16806s
run: gitlab-monitor: (pid 12460) 484s; run: log: (pid 19644) 16668s
run: gitlab-workhorse: (pid 12476) 484s; run: log: (pid 19489) 16688s
run: grafana: (pid 12485) 483s; run: log: (pid 19935) 16626s
run: logrotate: (pid 12503) 483s; run: log: (pid 19575) 16681s
run: nginx: (pid 12509) 482s; run: log: (pid 19507) 16687s
run: node-exporter: (pid 12594) 482s; run: log: (pid 19621) 16673s
run: postgres-exporter: (pid 12601) 481s; run: log: (pid 19848) 16643s
run: postgresql: (pid 12612) 481s; run: log: (pid 19225) 16801s
run: prometheus: (pid 12614) 481s; run: log: (pid 19730) 16656s
run: redis: (pid 12636) 480s; run: log: (pid 19060) 16812s
run: redis-exporter: (pid 12670) 480s; run: log: (pid 19686) 16663s
run: sidekiq: (pid 12677) 477s; run: log: (pid 19449) 16694s
run: unicorn: (pid 12685) 477s; run: log: (pid 19429) 16700s
sudo vim /etc/gitlab/gitlab.rb
更改ip域名
将文件中 external_url 'http://localhost' 改为external_url 'http://192.168.245.71'
更改访问端口
将文件中 nginx['listen_port'] = nil 改为nginx['listen_port'] = 8085
更改gitlab-nginx 的监听端口
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 *:8085; --修改端口
server_name localhost;
server_tokens off; ## Don't show the nginx version number, a security best practice
sudo gitlab-ctl reconfigure // 确认配置(修改配置后,必须执行
sudo gitlab-ctl start // 开启
即可访问http://ip:8085
注意若出现502错误
跟踪unicorn的状态
gitlab-ctl tail unicorn
查看端口unicorn 默认的8080端口是否被占用,更改这个端口
vim /etc/gitlab/gitlab.rb
unicorn['port'] = 9090
再gitlab-ctl reconfigure
重启配置,这样GitLab服务器就可以正常运行了。
sudo gitlab-ctl stop // 停止
sudo gitlab-ctl start // 开启
sudo gitlab-ctl restart // 重启
sudo gitlab-ctl status // 查看状态
sudo gitlab-ctl reconfigure // 确认配置(修改配置后,必须执行)
sudo gitlab-ctl tail // 查看日志
server
{
listen 80;
listen 443 ssl http2;
server_name 192.168.245.71;
root /www/wwwroot;
charset utf-8;
gzip on;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location /users/ {
proxy_pass http://192.168.245.71:8085;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location /assets/ {
alias /opt/gitlab/embedded/service/gitlab-rails/public/assets/;
}
}
sudo gitlab-ctl uninstall
sudo dpkg -r gitlab-ce
sudo rpm -e gitlab-ce
reboot //(重启)