Ubuntu虚拟机安装及配置GitLab CE

安装Ubuntu

虚拟机安装,分配300G空间

安装

安装链接

sudo apt-get update
sudo apt-get upgrade
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt-get install gitlab-ce=14.1.1-ce.0

配置

邮箱配置

sudo gedit /etc/gitlab/gitlab.rb

主要修改以下内容:
发件邮箱配置,用于发送验证邮件、通知等,可参考文档netease-free-enterprise-email

Aliyun Enterprise Mail with TLS

Aliyun Enterprise Mail with TLS (阿里企业邮箱)

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qiye.aliyun.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "username@your domain"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_domain'] = "your domain"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = false
gitlab_rails['smtp_tls'] = true

作出对应的修改:

### Request duration
###! Tells the rails application how long it has to complete a request
###! This value needs to be lower than the worker timeout set in puma.
###! By default, we'll allow 95% of the the worker timeout
# gitlab_rails['max_request_duration_seconds'] = 57

### GitLab email server settings
###! Docs: https://docs.gitlab.com/omnibus/settings/smtp.html
###! **Use smtp instead of sendmail/postfix.**

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qiye.aliyun.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "gitlab@datasheep.cn"
gitlab_rails['smtp_password'] = "your password"
gitlab_rails['smtp_domain'] = "datasheep.cn"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = false
gitlab_rails['smtp_tls'] = true
# gitlab_rails['smtp_pool'] = false

###! **Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert'**
###! Docs: http://api.rubyonrails.org/classes/ActionMailer/Base.html
# gitlab_rails['smtp_openssl_verify_mode'] = 'none'

# gitlab_rails['smtp_ca_path'] = "/etc/ssl/certs"
# gitlab_rails['smtp_ca_file'] = "/etc/ssl/certs/ca-certificates.crt"

### Email Settings

gitlab_rails['gitlab_email_enabled'] = true

##! If your SMTP server does not like the default 'From: gitlab@gitlab.example.com'
##! can change the 'From' with this setting.
gitlab_rails['gitlab_email_from'] = 'gitlab@datasheep.cn'
# gitlab_rails['gitlab_email_display_name'] = 'Example'
# gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com'
# gitlab_rails['gitlab_email_subject_suffix'] = ''
# gitlab_rails['gitlab_email_smime_enabled'] = false
# gitlab_rails['gitlab_email_smime_key_file'] = '/etc/gitlab/ssl/gitlab_smime.key'
# gitlab_rails['gitlab_email_smime_cert_file'] = '/etc/gitlab/ssl/gitlab_smime.crt'
# gitlab_rails['gitlab_email_smime_ca_certs_file'] = '/etc/gitlab/ssl/gitlab_smime_cas.crt'
# user['git_user_name'] = "GitLab"
user['git_user_email'] = "gitlab@datasheep.cn"
#"gitlab@#{node['fqdn']}"

验证邮件服务

# 验证邮件服务
# 需要等待一定时间
# 若在 action run步骤 卡了,请查看https://blog.csdn.net/diwan2439/article/details/102213324
sudo gitlab-ctl reconfigure

sudo gitlab-ctl restart

sudo gitlab-rails console

# 若失败,可查看
# https://www.pianshen.com/article/4198300157/
# https://www.jianshu.com/p/7f9ef8d6608a
# https://blog.csdn.net/liuruiqun/article/details/50000213
Notify.test_email('XXXXX@XX.com', 'test gitlab', 'test body').deliver_now

成功后会收到邮件:

root密码配置

gitlab-rails console production
Loading production environment (Rails 4.2.8)
irb(main):001:0> u=User.find(1)
=> #<User id:1 @root>
irb(main):002:0> u.password='12345678'
=> "12345678"
irb(main):003:0> u.save
Enqueued ActionMailer::DeliveryJob (Job ID: 1657620e-55fb-4786-a0d1-dec1fbc1421d) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1
=> true
irb(main):004:0> exit

此处可以设置root用户的密码,随便设置一个登录后可以通过web界面修改。

访问地址修改

external_url 'http://your-ip or domin'

访问地址对应的端口(如果选择使用80,则无需配置)

 nginx['listen_port'] = your-port

由于我安装在虚拟机,不过虚拟机使用的网络模式是直接连接物理网络,在路由器上设置端口映射即可,这里有一个坑,开始设置的端口是6666,发现使用公网地址怎么都打不开,但局域网内部又是正常的,后来才知道6666端口被列为不安全端口。
chrome不安全端口列表:

  1,    // tcpmux
  ...   //省略
  6000, // X11
  6665, // Alternate IRC [Apple addition]
  6666, // Alternate IRC [Apple addition]
  6667, // Standard IRC [Apple addition]
  6668, // Alternate IRC [Apple addition]
  6669, // Alternate IRC [Apple addition]

配置HTTPS

修改/etc/gitlab/gitlab.rb中的 external_url :

external_url 'https://dsm.datasheep.cn:320'
nginx['listen_port'] = 320

禁用 Let’s Encrypt:

letsencrypt['enable'] = false

创建/etc/gitlab/ssl目录并把证书放在该目录:

sudo mkdir -p /etc/gitlab/ssl
sudo chmod 755 /etc/gitlab/ssl
sudo cp gitlab.example.com.key gitlab.example.com.crt /etc/gitlab/ssl/

这里我从阿里云下载已经申请的免费证书


注意命名为/etc/gitlab/ssl/gitlab.example.com.key/etc/gitlab/ssl/gitlab.example.com.crt

设置重定向:

nginx['redirect_http_to_https'] = true

设置ssl证书创建/etc/gitlab/ssl目录的位置,在目录下放置.crt.key文件,并指定如下配置:

# For GitLab 
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.com.crt" 
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key"

至此,已经可以正常通过https方式访问gitlab

参考

ubuntu安装GitLab笔记
GitLab Docs
ubuntu搭建、安装gitlab服务器以及初始化密码
Chrome 错误代码:ERR_UNSAFE_PORT

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇