CentOS7.* gitlab安装及邮箱配置

1.在CentOS系统上,下面的命令将会打开系统防火墙HTTP和SSH访问。

sudo yum install curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld

2.添加GitLab镜像源并安装

curl -sS http://packages.gitlab.com.cn/install/gitlab-ce/script.rpm.sh | sudo bash

这是官方的yum源,安装速度会比较慢,可以使用国内源,修改如下文件即可:

vim /etc/yum.repos.d/gitlab_gitlab-ce.repo

修改内容如下:

[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key

然后执行:

sudo yum install gitlab-ce

#配置并启动 GitLab

sudo gitlab-ctl reconfigure

//邮箱配置

gitlab-ctl reconfigure

禁用gitlab自带Nginx 并把 UNIX套接字 更改为 TCP端口
禁用捆绑的Nginx

vim /etc/gitlab/gitlab.rb

nginx['enable'] = true

修改为

nginx['enable'] = false

并去掉注释 (前边的#)

允许gitlab-workhorse监听TCP(默认端口8181),编辑/etc/gitlab/gitlab.rb:

gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"

运行 sudo gitlab-ctl reconfigure 使更改生效。
通过系统原本安装的Nginx反代以便提供访问

server {
    listen       80;
    server_name  gitlab.edevops.top;

    location / {
        root  html;
        index index.html index.htm;
        proxy_pass http://127.0.0.1:8181;
    }
}

反向代理后无法访问静态文件 nginx中加配置 如下
#配置静态资源 解决js css文件无法加载无法访问的问题,注意末尾不能有 /

location ~ .*\.(js|css|jpg|jpeg|gif|png|ico|pdf|txt)$ {
                    proxy_pass http://127.0.0.1:8099;
     }

重启nginx

gitlab配置

external_url 'http://gitlab.xiaobainet.cn'

gitlab_rails['gitlab_email_from'] = '[email protected]'

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "123456"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true

user['git_user_email'] = "[email protected]"
                                          完毕

你可能感兴趣的:(git,gitlab,运维,nginx,linux,centos,gitlab,git)