Centos7.5快速安裝Git Gitlab詳細過程

一,安裝Git

使用的yum安裝

[root@localhost ~]# yum install curl-devel expat-devel gettext-devel  openssl-devel zlib-devel

[root@localhost ~]# yum install -y git

下載各種版本的git

https://mirrors.edge.kernel.org/pub/software/scm/git/

首先安裝依賴(以下都是在/usr/local目錄下完成)#root用戶運行

編譯時如果操作系統沒有安裝gcc,使用yum –y install gcc*

yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel tar -zxvf git-2.3.1.tar.gz cd git-2.3.1 make prefix=/usr/local all make prefix=/usr/local install
安裝完成後輸入git --version,會顯示對應的版本號,若現實的版本號不對(之前操作系統存在git),可以先卸載之前的版本,然後做一個軟鏈接,命令如下:

ln –s /usr/local/bin/git /usr/bin/

在Git用戶下安裝SSH

配置SSH免密登錄:

ssh-keygen -t rsa -C "[email protected]"

生成公私鑰,cat公鑰id_rsa.pub,複製到GitHub或者Gitlab seting SSHkey裏就OK

查看git github配置是否通。

ssh -T [email protected]

全局配置用戶名及郵箱

git config --global user.name "zhangxm"

全局配置郵箱

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

[root@Git-GitLab /]# mkdir gitdata

[root@Git-GitLab gitdata]# mkdir repository

[root@Git-GitLab repository]# git init

Git 安裝完成

===================================================================

二,安裝Gitlab

下載gitlab-ce社區免費版,gitlab-ee是企業收費的。

下載清華大學開源軟件鏡像站
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/

1. yum install curl openssh-server openssh-clients postfix cronie

2. sudo service postfix start  #GitLab使用postfix發送郵件

3. sudo chkconfig postfix on   #設置postfix開機自啓動

4. sudo lokkit -s http -s ssh  #配置iptables開放http和ssh端口,這裏需要注意,騰訊雲安全組選擇那裏要選擇開放所有端口

5. rpm -i gitlab-ce-10.6.5-ce.0.el6.x86_64.rpm   #安裝

6. centos 7 部署升級 gitlab-ce-10.*.* 提示 error: Failed dependencies:

    10.x以後開始依賴policycoreutils-python,我之前在使用9.x時還沒有依賴該項,升級時會提示安裝gitlab的依賴項
    yum install policycoreutils-python

7. 配置與啓動GitLab 執行下面的命令即可 
    gitlab-ctl reconfigure

安裝完成!

在瀏覽器中直接輸入http://localhost來訪問GitLab 註冊一個用戶OK

====================================================

刪除git

yum remove git

 

完全卸載GitLab
一、停止gitlab
    sudo gitlab-ctl stop
二、卸載gitlab(這塊注意了,看看是gitlab-ce版本還是gitlab-ee版本,別寫錯誤了)
    sudo rpm -e gitlab-ce

三、查看gitlab進程

    ps -ef|grep gitlab
     殺掉第一個守護進程(runsvdir -P /opt/gitlab/service log)
     kill -9 4473
     再次查看gitlab進程是否存在

四、刪除gitlab文件

        find / -name *gitlab*|xargs rm -rf      刪除所有包含gitlab的文件及目錄

        find / -name gitlab |xargs rm -rf 

        刪除gitlab-ctl uninstall時自動在root下備份的配置文件(ls /root/gitlab* 看看有沒有,有也刪除)

通過以上幾步就可以徹底卸載gitlab
==============================================

5.GitLab常用命令

sudo gitlab-ctl start                    # 啓動所有 gitlab 組件;
sudo gitlab-ctl stop                    # 停止所有 gitlab 組件;
sudo gitlab-ctl restart                # 重啓所有 gitlab 組件;
sudo gitlab-ctl status                 # 查看服務狀態;
sudo gitlab-ctl reconfigure         # 啓動服務;
sudo vim /etc/gitlab/gitlab.rb      # 修改默認的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace    # 檢查gitlab;
sudo gitlab-ctl tail                        # 查看日誌;
--------------------- 
 

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