1. 程式人生 > >gitlab搭建方法以及我所遇到的502問題

gitlab搭建方法以及我所遇到的502問題

阿里雲伺服器centos7.4 gitlab搭建方法以及我所遇到的502問題

搭建步驟

環境:阿里雲主機(CPU: 1核 記憶體:2 GB (I/O優化) 1Mbps),系統:centos7.4。

  1. 下載gitlib安裝包,下載地址:https://packages.gitlab.com/gitlab/gitlab-ce
    https://packages.gitlab.com/gitlab/gitlab-ce
    也可以使用curl下載(幾百兆下下來太慢,放棄) :
    curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh

    | sudo bash

  2. 下載完成後使用ftp工具上傳到伺服器;
    我使用的是filezilla(下載地址:https://filezilla-project.org/),直接上傳到了雲主機opt目錄

  3. 安裝gitlab;
    命令:
    sudo yum install -y curl policycoreutils-python openssh-server
    sudo systemctl enable sshd
    sudo systemctl start sshd
    sudo firewall-cmd --permanent --add-service=http
    sudo systemctl reload firewalld
    sudo yum install postfix
    sudo systemctl enable postfix
    sudo systemctl start postfix
    sudo rpm -ivh /opt/gitlab-ce-11.3.12-ce.0.el7.x86_64.rpm
    結果圖:
    在這裡插入圖片描述


    安裝完成後,重啟

  4. 初始化配置;
    命令:
    gitlab-ctl reconfigure
    結果圖:
    在這裡插入圖片描述

  5. 開啟gitlab;
    命令:
    gitlab-ctl start
    結果圖:
    在這裡插入圖片描述

  6. 修改埠;
    cd var/opt/gitlab/nginx/conf
    vim gitlab-http.conf
    在這裡插入圖片描述
    我把80埠修改成8084 因為80埠已經佔用
    同時阿里雲控制檯網路安全組開放8084埠
    完畢後瀏覽器訪問ip:port應該可以進入gitlab登陸頁面

遇到的問題

訪問出現502錯誤,有兩種可能性
1:建議檢視8080埠是否被佔用!
如果是被佔用:
在etc/gitlab/gitlab.rb檔案下加入unicorn[‘port’] =8088 ,我的8088這個埠號沒被佔用
儲存退出!
2:原因是gitlab佔用記憶體太多,導致伺服器崩潰(我才2g的記憶體)
解決方案:
使用swap分割槽(

https://yq.aliyun.com/articles/52098)
本圖來源:https://yq.aliyun.com/articles/52098