-
查詢系統發行版本,尋找GitLab對應版本
$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
安裝過程參考《手把手教你 GitLab 的安裝及使用》,RHEL/CentOS用戶在rooot權限下,用yum或下載清華大學鏡像源:
新建文件 /etc/yum.repos.d/gitlab_gitlab-ce.repo 內容:
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
安裝依賴
#可忽略。CentOS7 卸載舊git,安裝新版git
yum install -y epel-release
rpm -ivh https://centos7.iuscommunity.org/ius-release.rpm
yum list git2u
yum install -y git2u
git --version
sudo yum install curl openssh-server openssh-clients postfix cronie -y
sudo service postfix start
sudo chkconfig postfix on
sudo lokkit -s http -s ssh # 這句用於防火牆,避免用戶通過ssh方式和http訪問。暫未執行
# 下面是怕redis和nginx沒依賴包,提前裝了試試
yum -y install gcc
yum install tcl
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel
yum -y install openssl openssl--devel
yum -y install pcre pcre-deve
yum -y install pcre-devel.i686
yum -y install make zlib zlib-devel gcc-c++ libtool
安裝鏡像源
# yum法
rm -f /var/run/yum.pid #若yum鎖定
yum list installed | grep gitlab
yum -y remove gitlab-ce.x86_64 #完全卸載刪除gitlab https://yq.aliyun.com/articles/114619
yum clean all
sudo yum makecache
sudo yum install gitlab-ce -y# 下載法 centos7版本用el7文件夾,最新版有問題時手動降級
cd /opt
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.7.7-ce.0.el7.x86_64.rpm
chmod 755 gitlab-ce-10.7.7-ce.0.el7.x86_64.rpm
rpm -ivh gitlab-ce-10.7.7-ce.0.el7.x86_64.rpm# 安裝完后,將external_url 'http://gitlab.example.com' 改為自己的域名ip,默認8080端口改為 8812
sudo gedit /etc/gitlab/gitlab.rb---
external_url 'http://192.168.1.251'
unicorn['port'] = 8812nginx['listen_port'] = 8813
---
# 對GitLab進行初始化配置
sudo gitlab-ctl reconfigure
sudo gitlab-ctl reconfigure初始化需等待一段時間,有卡住不動、依賴關系等大問題就刪了重裝低版本。有gitlab Reconfigured!說明成功。
注意:執行 reconfigure 命令會把gitlab的nginx組件的配置還原,導致自定義修改的端口以及域名等沒有。所以先初始化,再自定義修改。自定義修改gitlab並啟動
#外網訪問的端口,默認80改為 8813
sudo gedit /var/opt/gitlab/nginx/conf/gitlab-http.conf
---
server {
listen 192.168.1.251:8813;
server_name 192.168.1.251;
---sudo gedit /var/opt/gitlab/gitlab-rails/etc/unicorn.rb
listen "192.168.1.251:8812", :tcp_nopush => true#設置項目頁面中間http地址
sudo gedit /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: 192.168.1.251
port: 8813#設置項目頁面中間ssh地址
sudo gedit /var/opt/gitlab/gitlab-shell/config.yml
# Url to gitlab instance. Used for api calls. Should end with a slash.
gitlab_url: "http://192.168.1.251:8812"
#增加端口到防火牆配置中,執行以下操作:
iptables -I INPUT -p tcp --dport 8812 -j ACCEPT
iptables -I INPUT -p tcp --dport 8813 -j ACCEPT
iptables -L -n #查看防火牆
netstat -tln #查看端口#重啟gitlab,訪問http://192.168.1.251:8813
http://192.168.1.251:8813
gitlab-ctl restartsudo gitlab-ctl restart sidekiq sudo gitlab-ctl hup unicorn gitlab-ctl tail unicorn
訪問gitlab,第一次登陸時設置密碼gitlab-ctl start|stop|status|restart #管理
gitlab-ctl restart #重啟gitlab
在restart后,就可以直接訪問:http://192.168.1.251:8813 ,默認用戶名root,第一次登陸時設置密碼。
若有502問題,修改沖突的端口,或reboot重啟試試。
502太坑了……gitlab集成了各組件,所以要修改各組件具體的ip地址、端口號。
對於錯誤,及時查看日志文件和錯誤文件,如:
gitlab-shell.log
gitlab_access.log
unicorn_stderr.log
gitlab_error.log
一般都是127.0.0.1或端口沒改過來,即使gitlab網頁已經打開,上傳東西時也有可能上傳組件地址配錯,傳不上去。默認安裝的gitlab,主要有四個目錄:
/opt/gitlab/ ## 主目錄
/etc/gitlab/ ## 放置配置文件
/var/opt/gitlab/ ## 各個組件
/var/log/gitlab/ ## 放置日志文件檢查gitlab各組件狀態:
gitlab-ctl status重啟gitlab:
gitlab-ctl restart只重啟某個組件:
gitlab-ctl restart nginxgitlab組件:
nginx:
postgresql:
redis:
unicorn:
sidekiq:
logrotate:
---------------------
5 漢化 #可跳過這步cd /opt
wget https://gitlab.com/xhang/gitlab/repository/10-7-stable-zh/archive.tar.bz2 -O gitlab-10-7-stable-zh.tar.bz2
tar xf gitlab-10-7-stable-zh.tar.bz2
mv gitlab-10-7-stable-zh-c400d379745573f67a8961f41534bd4653136d8e gitlab-10-7-stable-zh
cat gitlab-10-7-stable-zh/VERSIONsudo gitlab-ctl stop
#先備份,避免漢化失敗后gitlab癱瘓
cp -r /opt/gitlab/embedded/service/gitlab-rails{,.ori}
\cp -rf gitlab-10-7-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/
忽略以下2個提示
cp: 無法以目錄"gitlab-10-7-stable-zh/log" 來覆蓋非目錄"/opt/gitlab/embedded/service/gitlab-rails/log"
cp: 無法以目錄"gitlab-10-7-stable-zh/tmp" 來覆蓋非目錄"/opt/gitlab/embedded/service/gitlab-rails/tmp"gitlab-ctl reconfigure
sudo gedit /etc/gitlab/gitlab.rb
sudo gedit /var/opt/gitlab/nginx/conf/gitlab-http.conf
gitlab-ctl restart
6 客戶端TortoiseGit安裝、配置Git簡介及安裝 https://www.cnblogs.com/xiuxingzhe/p/9300905.html
Git秘鑰生成以及Gitlab配置 https://www.cnblogs.com/xiuxingzhe/p/9303278.html
TortoiseGit安裝、配置 https://www.cnblogs.com/xiuxingzhe/p/9312929.html
手把手教你 GitLab 的安裝及使用
https://www.jianshu.com/p/b04356e014fa
完全卸載刪除gitlab
https://yq.aliyun.com/articles/114619
安裝GitLab出現ruby_block[supervise_redis_sleep] action run
https://www.cnblogs.com/springwind2006/p/6872773.html
搭建GitLab並漢化
https://www.jianshu.com/p/2400d9e57fd1
CentOS 7 上 GitLab 的安裝、備份、遷移及恢復
https://www.ifeegoo.com/the-installation-backup-migration-restore-of-gitlab-on-centos-7.html
我所遇到的GitLab 502問題的解決
https://blog.csdn.net/wangxicoding/article/details/43738137
Ubuntu 14.04下安裝GitLab指南
https://www.cnblogs.com/duyinqiang/p/5696435.html