本文記錄了在 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 查看日志。由於涉及組件較多,建議在乾淨的系統上部署。

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

[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

[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

[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

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