跳转至

Ubuntu20.04 架设Gitlab服务器

安装关联软件

cd ~
sudo apt-get install -y postfix

下载安装Gitlab服务端

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
sudo apt-get install gitlab-ee

修改配置文件

提前准备好网址的SSL证书并复制到/data/nginx/vhosts/

sudo mkdir -p /data/nginx/vhosts/
sudo vim /etc/gitlab/gitlab.rb
 external_url 'https://git.szpzhy.com'
 gitlab_rails['time_zone'] = 'Asia/Shanghai'

 gitlab_rails['smtp_enable'] = true
 gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
 gitlab_rails['smtp_port'] = 465
 gitlab_rails['smtp_user_name'] = "admin@szpzhy.com"
 gitlab_rails['smtp_password'] = "exmail_password"
 gitlab_rails['smtp_domain'] = "szpzhy.com"
 gitlab_rails['smtp_authentication'] = "login"
 gitlab_rails['smtp_enable_starttls_auto'] = false
 gitlab_rails['smtp_tls'] = true
 gitlab_rails['gitlab_email_enabled'] = true
 gitlab_rails['gitlab_email_from'] = 'admin@szpzhy.com'
 gitlab_rails['gitlab_email_display_name'] = 'Gitlab_git.szpzhy.com'


 git_data_dirs({
   "default" => {
     "path" => "/data/gitdata"
    }
 })

 nginx['ssl_certificate'] = "/data/nginx/ssl/git.szpzhy.com.pem"
 nginx['ssl_certificate_key'] = "/data/nginx/ssl/git.szpzhy.com.key"


 /etc/nginx/ssl/sz.sinnen.top.pem
 /etc/nginx/ssl/sz.sinnen.top.key

运行服务器

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

查看默认密码

sudo cat /etc/gitlab/initial_root_password
Password: eVelqbzSV2apBwUtq3InP1he6vas49vWyYqjTLupStc=
Password: SeC3jplcDARYzlXdHH0LjZPie3m2Jz7nbiCBL4jfSaY=

登陆修改密码和邮箱

  • 现在可以打开网址,并以上面默认生成的密码登陆
  • 修改密码和邮箱

使用Gitlab自带的nginx加载其他网站

  • 不推荐使用.推荐使用后装的NGINX代替自带的NGINX
sudo vim /etc/gitlab/gitlab.rb
 nginx['custom_nginx_config'] = "include /data/nginx/vhosts/*.conf;"

邮箱发送邮件测试

sudo gitlab-rails console
Notify.test_email('test@yourmail.com', '邮件主题', '邮件内容').deliver_now