gitlab从0搭建,配置采坑指南

如何在centos安装 gitlab 10.x

环境依赖

sudo yum -y install policycoreutils openssh-server openssh-clients postfix policycoreutils-python

下载最新的安装包

在找到最新版本https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

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

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

如下图
gitlab搭建

初次配置

初次启动 gitlab-ctl reconfigure 配置

gitlab-ctl reconfigure

报错

There was an error running gitlab-ctl reconfigure:
execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8] (postgresql::enable line 80) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.
STDERR: initdb: invalid locale settings; check LANG and LC_* environment variables
---- End output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
Ran /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 returned 1

解决:在 ~/.bash_profile, 然后source ~/.bash_profile

export LC_ALL="zh_CN.UTF-8"
export LC_CTYPE="zh_CN.UTF-8"

配置访问路径和端口并重新加载配置重启

配置 url端口 和 阿里云DNS

如果自己有自域名的话那么可以直接域名:端口。 端口不谢的话,默认80

    vi /etc/gitlab/gitlab.rb
    external_url 'http://gitlab.xxx.com'

它的原理是这样的, 其实gitlab安装结束以后会自动在后台安装PG数据库,和一个ngnix程序,这里配置的external_url会在ngnix那边生成一个反向代理的配置。

重新加载配置和重启gitlab

 gitlab-ctl reconfigure
 gitlab-ctl restart

配置阿里云DNS

把阿里云DNS 把gitlab.xxx.com 的域名指向当前ECS/EC2公网IP

通过域名在浏览器配置gitlab密码

访问 gitlab.xxx.com设置root密码
gitlab搭建

安全起见不要用root上传项目,创建people

配置 email

参照 官网教程设置邮箱。https://docs.gitlab.com/omnibus/settings/smtp.html

修改project的 url

ls -al 找到/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml对应的软连文件。


ls -al /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml

   /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml -> /var/opt/gitlab/gitlab-rails/etc/gitlab.yml

然后修改 /var/opt/gitlab/gitlab-rails/etc/gitlab.yml 的project url

 vi /var/opt/gitlab/gitlab-rails/etc/gitlab.yml
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: gitlab.xxxx.com
    port: 80
    https: false

运行

gitlab-ctl restart

大功告成,给一个效果图

gitlab 搭建

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
慷慨打赏