阿里雲部署git與gitlab

阿里雲服務器系統:CentOS 7.2 64

部署GitLab環境

1、安裝依賴包

sudo yum install -y curl policycoreutils-python openssh-server

2、設置SSH開機自啓動並啓動SSH服務

sudo systemctl enable sshd
sudo systemctl start sshd

3、安裝Postfix來發送通知郵件

sudo yum install postfix

4、設置Postfix開機自啓動

sudo systemctl enable postfix

5、啓動Postfix服務

  • 運行命令vim /etc/postfix/main.cf打開main.cf文件,找到下圖內容
    在這裏插入圖片描述
  • 這行代碼改爲inet_interfaces = all
  • 運行命令sudo systemctl start postfix啓動Postfix服務

6、添加GitLab軟件包倉庫

 curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

7、安裝GitLab

sudo EXTERNAL_URL="GitLab服務器的公網IP地址" yum install -y gitlab-ce

8、使用瀏覽器訪問GitLab服務器的公網IP地址。
返回頁面如下圖所示,表示環境搭建成功,並且您需要設置新密碼
在這裏插入圖片描述
9、登錄GitLab。
在瀏覽器的地址欄中,輸入ECS服務器的公網IP即可進入GitLab的登錄界面,首次登錄使用用戶名root,密碼爲首次訪問GitLab時設置的新密碼
在這裏插入圖片描述

安裝git

1、使用Linux自帶的軟件源安裝Git工具

yum install git

2、生成密鑰文件。
使用如下命令生成密鑰文件.ssh/id_rsa。

ssh-keygen

在這裏插入圖片描述
3、使用如下命令查看公鑰文件id_rsa.pub中的內容。在下一步操作中,您需要粘貼該內容到GitLab服務器的SSH-key的配置文件中。

cat .ssh/id_rsa.pub

在這裏插入圖片描述
在這裏插入圖片描述

簡單配置

1、配置使用Git倉庫的人員姓名。

git config --global user.name "testname" 

2、配置使用Git倉庫的人員email,填寫自己的公司郵箱

git config --global user.email "[email protected]" 

3、克隆項目,在本地生成同名目錄,並且目錄中會有所有的項目文件

git clone git@iZxxxxxxxxxxxxxxxxx3Z:root/test.git

修改gitlab默認端口

1、修改nginx端口

vi /etc/gitlab/gitlab.rb

在這裏插入圖片描述
2、修改

vi /var/opt/gitlab/nginx/conf/gitlab-http.conf

在這裏插入圖片描述
3、修改unicorn端口

vi /etc/gitlab/gitlab.rb

在這裏插入圖片描述
4、防火牆添加端口允許訪問

firewall-cmd --zone=public --permanent --add-port=8082/tcp

firewall-cmd --reload   防火牆重新加載配置
systemctl status firewalld 查看firewalld狀態
systemctl start firewalld  開啓防火牆
systemctl stop firewalld   關閉防火牆

5、保存配置,重啓

gitlab-ctl reconfigure
gitlab-ctl restart

6、安全組添加允許訪問端口
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章