阅读 158

前端必备技能之Gitlab服务器安装

Linux Centos7.6 安装Gitlab

注意: 服务器推荐2C4G

一、安装GitLab依赖包

$ yum -y install policycoreutils openssh-server openssh-clients postfix $ yum -y install policycoreutils-python   复制代码

postfix 用于发送邮件功能

二、设置postfix开启自启并启动

postfix 支持gitlab发信功能

$ systemctl enable postfix && systemctl start postfix 复制代码

三、下载Gitlab安装包并安装

centos7系统gitlab镜像地址 mirrors.tuna.tsinghua.edu.cn/gitlab-ce/y…

$ wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.1.8-ce.0.el7.x86_64.rpm --no-check-certificate $ rpm -i gitlab-ce-14.1.8-ce.0.el7.x86_64.rpm 复制代码

[root@VM-24-6-centos depends]#  wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.1.8-ce.0.el7.x86_64.rpm --no-check-certificate --2021-11-18 15:03:37--  https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.1.8-ce.0.el7.x86_64.rpm Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.15.130, 2402:f000:1:400::2 Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.15.130|:443... connected. WARNING: cannot verify mirrors.tuna.tsinghua.edu.cn's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=R3’:   Issued certificate has expired. HTTP request sent, awaiting response... 200 OK Length: 910639716 (868M) [application/x-redhat-package-manager] Saving to: ‘gitlab-ce-14.1.8-ce.0.el7.x86_64.rpm’ 100%[=====================================================================================>] 910,639,716 11.7MB/s   in 73s     2021-11-18 15:04:53 (11.8 MB/s) - ‘gitlab-ce-14.1.8-ce.0.el7.x86_64.rpm’ saved [910639716/910639716] 复制代码

安装成功

[root@VM-24-6-centos depends]# rpm -i gitlab-ce-14.1.8-ce.0.el7.x86_64.rpm warning: gitlab-ce-14.1.8-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY It looks like GitLab has not been configured yet; skipping the upgrade script.        *.                  *.       ***                 ***      *****               *****     .******             *******     ********            ********    ,,,,,,,,,***********,,,,,,,,,   ,,,,,,,,,,,*********,,,,,,,,,,,   .,,,,,,,,,,,*******,,,,,,,,,,,,       ,,,,,,,,,*****,,,,,,,,,.          ,,,,,,,****,,,,,,             .,,,***,,,,                 ,*,.         _______ __  __          __     / ____(_) /_/ /   ____ _/ /_    / / __/ / __/ /   / __ `/ __ \   / /_/ / / /_/ /___/ /_/ / /_/ /   \____/_/\__/_____/\__,_/_.___/    Thank you for installing GitLab! GitLab was unable to detect a valid hostname for your instance. Please configure a URL for your GitLab instance by setting `external_url` configuration in /etc/gitlab/gitlab.rb file. Then, you can start your GitLab instance by running the following command:   sudo gitlab-ctl reconfigure For a comprehensive list of configuration options please see the Omnibus GitLab readme https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md Help us improve the installation experience, let us know how we did with a 1 minute survey: https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=14-1 复制代码

四、修改Gitlab配置文件执行服务器IP和自定义端口号

$ vim /etc/gitlab/gitlab.rb #  配置域名 external_url 'http://IP:端口号' # 配置邮件,因为添加用户的时候,会通过发邮件给用户去设置密码,所以有必要配置邮箱部分 gitlab_rails['gitlab_email_enabled'] = true gitlab_rails['gitlab_email_from'] = 'xxxxxx@mail.com' gitlab_rails['gitlab_email_display_name'] = 'GitLab Server' #启用 SMTP  gitlab_rails['smtp_enable'] = true #发件人地址 gitlab_rails['smtp_address'] = "smtp.mail.com" #启用的端口 gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "xxxxx@mail.com" #密码 gitlab_rails['smtp_password'] = "xxxxx" gitlab_rails['smtp_domain'] = "mail.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true user['git_user_name'] = "GitLab" user['git_user_email'] = "xxxxxx@mail.com" 复制代码

五、使配置生效并重启Gitlab

$ gitlab-ctl reconfigure # 使配置生效 $ gitlab-ctl restart # 重启gitlab 复制代码

 ok: run: postgres-exporter: (pid 12448) 0s ok: run: postgresql: (pid 12534) 1s ok: run: prometheus: (pid 12552) 0s ok: run: puma: (pid 12565) 0s ok: run: redis: (pid 12571) 1s ok: run: redis-exporter: (pid 12625) 0s ok: run: sidekiq: (pid 12642) 0s 复制代码

常用命令

gitlab-ctl start 启动 gitlab-ctl stop 停止 gitlab-ctl restart 重启 gitlab-ctl reconfigure 重新生成配置 复制代码

六、访问Gitlab页面

image-20211118152317297.png

七、查看Gitlab 初始密码 默认账号root

$ cat /etc/gitlab/initial_root_password [root@VM-24-6-centos depends]# cat /etc/gitlab/initial_root_password # WARNING: This value is valid only in the following conditions #          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run). #          2. Password hasn't been changed manually, either via UI or via command line. # #          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password. Password: XXXXXXXXXXXXXXX # NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours. [root@VM-24-6-centos depends]#  复制代码

常见问题

一、缺少policycoreutils-python 依赖

[root@VM-24-6-centos depends]# rpm -i gitlab-ce-14.1.8-ce.0.el7.x86_64.rpm warning: gitlab-ce-14.1.8-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY error: Failed dependencies: policycoreutils-python is needed by gitlab-ce-14.1.8-ce.0.el7.x86_64 # 安装依赖  $ yum -y install policycoreutils-python   复制代码

拓展

centos 查看版本命令

[root@VM-24-6-centos ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core)


作者:墩墩大魔王丶
链接:https://juejin.cn/post/7032604825489506311


文章分类
前端
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐