Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

CentOS 7 本地部署 GitLab(CE 版)完整實錄

本文記錄了在 CentOS 7 上部署本地 GitLab(CE 社區版)的完整過程,主要參照官方文檔。

安裝步驟

[root@localhost ~]# sudo yum install curl policycoreutils openssh-server openssh-client -y
[root@localhost ~]# sudo systemctl enable sshd
[root@localhost ~]# sudo systemctl start sshd
[root@localhost ~]# sudo yum install postfix -y
[root@localhost ~]# sudo systemctl enable postfix
[root@localhost ~]# sudo systemctl start postfix
[root@localhost ~]# sudo firewall-cmd --permanent --add-service=http
[root@localhost ~]# sudo systemctl reload firewalld
[root@localhost ~]# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
[root@localhost ~]# sudo yum install gitlab-ce

安裝完成後,可用 gitlab-ctl status 查看各組件(nginx、postgresql、redis、sidekiq、unicorn 等)運行狀態,並以 gitlab-ctl restart 重啟、gitlab-ctl tail 查看日志。由於涉及組件較多,建議在乾淨的系統上部署。

CentOS 7 本地部署 GitLab(CE 版)完整實錄

初始化與登錄

首次訪問會要求設置初始密碼,配置完成後以 root 用戶及該密碼登錄。

CentOS 7 本地部署 GitLab(CE 版)完整實錄

配置 SSH 密鑰

[root@localhost code]# ssh-keygen -t rsa
[root@localhost .ssh]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2E... root@localhost.localdomain

將公鑰內容複製到 GitLab 的指定區域保存,即可用私鑰認證。同時可為 git 配置顏色:

[root@localhost code]# git config --global color.ui true
[root@localhost code]# git config --list
CentOS 7 本地部署 GitLab(CE 版)完整實錄

克隆與推送

[root@localhost code]# git clone git@localhost:root/cslc.git
[root@localhost cslc]# cp /etc/passwd .
[root@localhost cslc]# git add passwd
[root@localhost cslc]# git commit -m "add passwd"
[root@localhost cslc]# git push -u origin master
CentOS 7 本地部署 GitLab(CE 版)完整實錄

添加 README

[root@localhost cslc]# echo "歡迎來到 GitLab 站" >> README.MD
[root@localhost cslc]# git add README.md
[root@localhost cslc]# git commit -m "add README"
[root@localhost cslc]# git push -u origin master
CentOS 7 本地部署 GitLab(CE 版)完整實錄

至此,GitLab 的本地安裝與基本使用便完成了。

Copyright © Linux教程網 All Rights Reserved