centos 安裝gitlab

1.開始安裝依賴軟件:yum -y install policycoreutils openssh-server openssh-clients postfix

2.設置postfix開機自啓動,postfix支持gitlab發信功能:systemctl enable postfix && systemctl start postfix

如果出現:

Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.

vim /etc/postfix/main.cf

inet_protocols = ipv4
inet_interfaces = all

3.下載gitlab包(建議去網站下載最新版本https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/?C=M&O=A)

   wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.3.3-ce.0.el7.x86_64.rpm

   rpm -i gitlab-ce-11.3.3-ce.0.el7.x86_64.rpm

  如果報錯:

   error: Failed dependencies:

        policycoreutils-python is needed by gitlab-ce-10.7.3-ce.0.el7.x86_64

   安裝環境

   yum install policycoreutils-python

 

  別的網站下載後有時候會報錯

   

 

 

4.修改gitlab 端口和ip

   vim /etc/gitlab/gitlab.rb

   IP地址+端口號: external_url 'http://192.168.0.217:8010'

5.配置並啓動gitlab

   gitlab-ctl reconfigure (可能會一段時間)

   gitlab-ctl restart

  下圖表示成功

 

6.頁面打開 如果出現這個錯誤

 

   1.更改端口號 vim  /etc/gitlab/gitlab.rb(更改後要重新運行)   

      gitlab-ctl reconfigure (可能會一段時間)

      gitlab-ctl restart

   2.權限問題,解決方法:chmod -R 755 /var/log/gitlab

   3.內存大於4G

7.首次進入會讓你修改密碼:修改後進入

.後來把端口改爲8081後就可以了

9.創建用戶 

    1.點擊小工具

    2.添加user

  

10.關於發送郵箱。postfix默認用的25端口,但是阿里雲又不讓開啓25端口。

 vim /etc/gitlab/gitlab.rb

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"  # 你自己QQ號
gitlab_rails['smtp_password'] = "*************"             # QQ授權碼
gitlab_rails['smtp_domain'] = "smtp.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'   # 你自己QQ號

3.打開自己的qq郵箱

 打開QQ郵箱-設置-賬戶-帳戶安全-開啓服務-POP3/SMTP服務-生成授權碼-發個短信

gitlab-ctl reconfigure 重新配置

4.進入gitlab-rails console

  Notify.test_email('yoyo_你自己隨便郵箱@qq.com', '郵件標題_test', '郵件正文_test').deliver_now

[root@iZ2ze9m7ocdxc43mxwv5uwZ ~]# gitlab-rails console
-------------------------------------------------------------------------------------
 GitLab:       11.11.0 (3e8ca2fb781)
 GitLab Shell: 9.1.0
 PostgreSQL:   9.6.11
-------------------------------------------------------------------------------------
Loading production environment (Rails 5.1.7)
irb(main):001:0> Notify.test_email('[email protected]','標題黨','正文').deliver_now
Notify#test_email: processed outbound mail in 189.3ms
Sent mail to [email protected] (1514.7ms)
Date: Mon, 27 May 2019 15:56:21 +0800
From: GitLab <[email protected]>
Reply-To: GitLab <[email protected]>
To: [email protected]
Message-ID: <[email protected]>
Subject: =?UTF-8?Q?=E6=A0=87=E9=A2=98=E5=85=9A?=
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Auto-Submitted: auto-generated
X-Auto-Response-Suppress: All

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><p>正文</p></body></html>

=> #<Mail::Message:70328290558700, Multipart: false, Headers: <Date: Mon, 27 May 2019 15:56:21 +0800>, <From: GitLab <[email protected]>>, <Reply-To: GitLab <[email protected]>>, <To: [email protected]>, <Message-ID: <[email protected]>>, <Subject: 標題黨>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>, <Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>>
irb(main):002:0> exit()
[root@iZ2ze9m7ocdxc43mxwv5uwZ ~]# 

5.現在創建用戶就會發送郵件

 

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