Gitlab安裝
基礎包安裝
yum install -y curl policycoreutils-python openssh-server
systemctl enable sshd
systemctl start sshd
firewall-cmd --permanent --add-service=http
systemctl reload firewalld
安裝 postfix
yum install postfix
systemctl enable postfix
systemctl start postfix
添加Gitlab包的yum庫
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
安裝gitlab
EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ce
vi /etc/gitlab/gitlab.rb 修改 EXTERNAL_URL=“http://IP:port”
漢化
下載最新漢化包
git clone https://gitlab.com/xhang/gitlab.git
- 下載指定版本漢化包
git clone https://gitlab.com/xhang/gitlab.git -b v12.0.6-zh
查看漢化補丁版本
cat gitlab/VERSION
獲取漢化包
git diff 12.0.6-stable 12.0.6-stable-zh > ../12.0.6.diff
更新補丁到gitlab中
yum install patch -y #安裝patch工具
patch -d/opt/gitlab/embedded/service/gitlab-rails -p1 < 10.7.diff
重新配置gitlab
gitlab-ctl reconfigure #重載配置
gitlab-ctl start #啓動gitlab
常用管理命令
gitlab-ctl start # 啓動所有 gitlab 組件;
gitlab-ctl stop # 停止所有 gitlab 組件;
gitlab-ctl restart # 重啓所有 gitlab 組件;
gitlab-ctl status # 查看服務狀態;
vim /etc/gitlab/gitlab.rb # 修改gitlab配置文件;
gitlab-ctl reconfigure # 重新編譯gitlab的配置;
gitlab-rake gitlab:check SANITIZE=true --trace # 檢查gitlab;
gitlab-ctl check-config #檢查在gitlab中是否有任何配置。在指定版本中刪除的rb
gitlab-ctl deploy-page #安裝部署頁面
gitlab-ctl diff-config #將用戶配置與包可用配置進行比較
gitlab-ctl remove-accounts #刪除所有用戶和組
gitlab-ctl upgrade #升級
gitlab-ctl service-list #查看所有服務
gitlab-ctl tail # 查看日誌;
gitlab-ctl tail nginx/gitlab_access.log
gitlab-ctl help # 查看相關的幫助
gitlab-ctl once #如果GitLab服務停止了就啓動服務,如果已啓動就不做任何操作
GitLab配置文件修改
vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
#外網訪問的端口,如果服務器已經有服務器佔用了80,那麼這裏可以改成其它
listen *:8888;
server_name gitlab.test.domain.com;
set $http_host_with_default "gitlab.test.domain.com:8888";
gitlab基本配置:
#外部訪問url(經過編譯後,自動將這個配置編譯到nginx配置,nginx就無需配置了)
external_url 'http://gitlab.test.domain.com:8888'
#默認值就是8080。如果端口被佔用,可將8080修改爲其它(例如:9090)
unicorn['port'] = 8080
gitlab發送郵件配置
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = “smtp.exmail.qq.com”
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = “[email protected]“
gitlab_rails['smtp_password'] = "smtp password"
gitlab_rails['smtp_authentication']= “plain"
gitlab_rails['smtp_enable_starttls_auto']= true
gitlab_rails['gitlab_email_from']= '[email protected]'
gitlab_rails['gitlab_email_reply_to']= ‘[email protected]'
服務器修改過ssh端口的坑(需要修改配置ssh端口)
#修改過ssh端口,gitlab中項目的的ssh地址,會在前面加上協議頭和端口號
“ssh://[email protected]:55725/huangdc/test.git”
gitlab_rails['gitlab_shell_ssh_port'] = 55725
更換gitlab服務器ip的地址
cd /opt/gitlab/embedded/service/gitlab-rails/config
vim gitlab.yml
依據自己的情況,更換地址,該地址影響項目代碼的地址
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
#host: 192.168.13.42
#port: 9988
host: gitlab.test.com
port: 80
https: false
配置生效
#使配置生效
gitlab-ctl reconfigure
#重新啓動GitLab
gitlab-ctl restart