做網(wǎng)站制作的摘要網(wǎng)店推廣策劃書
當(dāng)設(shè)置和配置 GitLab 實例并執(zhí)行諸如創(chuàng)建群組、項目、用戶和上傳代碼等操作時,涉及到多個步驟,每個步驟都有特定的目的。讓我們逐步解釋每個步驟并說明其背后的原因:
- 安裝必需的軟件:
yum install -y curl policycoreutils-python openssh-server perl postfix
此命令安裝了必要的軟件包,包括命令行工具 curl、用于 SELinux 策略管理的 policycoreutils、用于遠(yuǎn)程訪問的 OpenSSH 服務(wù)器、用于腳本編寫的 Perl,以及用于郵件服務(wù)的 Postfix。
2.啟用 SSH 和 Postfix:
systemctl enable --now sshd postfix
此命令啟用并啟動了 SSH 服務(wù)器和 Postfix 郵件服務(wù)。SSH 用于遠(yuǎn)程訪問服務(wù)器,而 Postfix 用于發(fā)送電子郵件通知,GitLab 可能會用于警報和用戶通知。
3.安裝 GitLab:
下面獲取?gitlab-ce-12.3.0-ce.0.el7.x86_64.rpm 文件
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm --no-check-cetificate
rpm -ivh gitlab-ce-12.3.0-ce.0.el7.x86_64.rpm?安裝了指定版本的 GitLab 社區(qū)版軟件包。
4.配置 GitLab 設(shè)置 (
vim /etc/gitlab/gitlab.rb
):vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.179.20:82' ... nginx['listen_port'] = 82
external_url 'http://192.168.179.20:82'
:設(shè)置 GitLab 的外部 URL,以便從中訪問。在此情況下,配置為使用http://192.168.179.20:82
。nginx['listen_port'] = 82
:配置 Nginx Web 服務(wù)器以監(jiān)聽端口 82。
5.重新配置和重啟 GitLab:
gitlab-ctl reconfigure:根據(jù)
gitlab.rb
中的設(shè)置重新配置 GitLab。
gitlab-ctl restart :重新啟動 GitLab 服務(wù)以應(yīng)用更改。
6.通過瀏覽器訪問 GitLab:
瀏覽器訪問:http://192.168.179.20:82 ,訪問 GitLab 實例。如果出現(xiàn) "502 Bad Gateway" 錯誤,建議用戶稍等片刻,然后刷新頁面。
1、設(shè)置管理員 root 用戶的新密碼,注意有格式要求,這里設(shè)置成 root@123
2、使用管理員 root 用戶登錄(root/root@123)
3、登錄后點擊頁面右上方的用戶選項下拉選擇【Settings】,點擊左邊菜單【Preferences】,在【Localization】的【Language】中選擇【簡體中文】,點擊【Save changes】按鈕,再刷新頁面使用中文顯示。
//Gitlab添加組、創(chuàng)建用戶、創(chuàng)建項目
#創(chuàng)建群組
點擊頁面左上方的【GitLab】圖標(biāo),點擊 【新建群組】
【群組名稱】、【群組URL】、【群組描述】都設(shè)置成 devops_group
【可見性級別】設(shè)置成 私有
其他都保持默認(rèn)值,點擊 【創(chuàng)建群組】
#創(chuàng)建項目
點擊 【新建項目】
【項目URL】群組選項下拉選擇 devops_group
【項目名稱】設(shè)置成 web_demo
【項目描述】設(shè)置成 web_demo
【可見等級】設(shè)置成 私有
點擊 【創(chuàng)建項目】
#創(chuàng)建用戶
點擊頁面上方的【扳手】圖標(biāo)進入“管理區(qū)域”
點擊 【新建用戶】
【姓名】設(shè)置成 zhangsan
【用戶名】設(shè)置成 zhangsan
【電子郵箱】設(shè)置成 zhangsan@xny.com
這里密碼暫不設(shè)置,其他都保持默認(rèn)值,先點擊 【創(chuàng)建用戶】
注:Access level:Regular(表示的是普通用戶,只能訪問屬于他的組和項目);Admin(表示的是管理員,可以訪問所有組和項目)
創(chuàng)建好用戶后再點擊右上角的【Edit】,可在這里設(shè)置密碼,如 zhangsan@123
#將用戶添加到組中
點擊頁面上方的【群組】下拉選擇 devops_group
點擊"向群組添加用戶"菜單【成員】
【添加成員到 devops_group】在search for a user選擇 zhangsan,角色權(quán)限選擇 Owner
點擊 【添加到群組】
#使用自己創(chuàng)建的賬戶進行管理
退出當(dāng)前賬戶,使用自己創(chuàng)建的賬戶 zhangsan 登錄(zhangsan/zhangsan@123)
第一次登錄會被強制要求修改密碼(zhangsan/zhangsan@123),可與舊密碼相同,再重新登錄
#源碼上傳到Gitlab倉庫
可能現(xiàn)需要yum下載git
yum install git -y
否則會command not fount?
git config --global user.name "zhangsan"
git config --global user.email "zhangsan@xny.com"
cd ~
git clone http://192.168.179.20:82/devops_group/web_demo.git ? ? ? #賬號/密碼:zhangsan/zhangsan@123
ls -A web_demo/
上傳 web_demo.zip 文件到 /opt 目錄
cd /opt
unzip web_demo.zip?
mv web_demo/* /root/web_demo/
cd /root/web_demo
git add .
git commit -m "init web_demo"
git push -u origin master ? ? ? ? ? ? ? ?#賬號/密碼:zhangsan/zhangsan@123
[root@localhost web_demo]# git push -u origin master
Username for 'http://192.168.179.20:82': zhangsan
Password for 'http://zhangsan@192.168.179.20:82':
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (10/10), 1.66 KiB | 0 bytes/s, done.
Total 10 (delta 0), reused 0 (delta 0)
To http://192.168.179.20:82/devops_group/web_demo.git* [new branch] master -> master
Branch master set up to track remote branch master from origin.
[root@localhost web_demo]#
點擊頁面上方的【項目】下拉選擇 web_demo,即可看到上傳的代碼