linux 安装gitlab

安装环境

  • CentOS 7.7 (centos6.10会报错)
  • 2g内存
  • 防火墙关闭

安装步骤:

1 安装gitlab
复制代码
# yum install -y git curl policycoreutils-python openssh-server        # 安装依赖
# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm        # 下载软件包
# yum -y install gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm              # 安装gitlab
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
2 配置gitlab修改成本机ip地址
复制代码
# vim /etc/gitlab/gitlab.rb               # 编辑配置文件  
external_url 'http://192.168.1.21'        # 改为自己的IP地址

# gitlab-ctl reconfigure                  # 第一次使用gitlab需要初始化gitlab服务(时间相对较长)
.........
........
Recipe: gitlab::postgres-exporter
  * service[postgres-exporter] action restart
    - restart service service[postgres-exporter]
  * ruby_block[reload postgres-exporter svlogd configuration] action create
    - execute the ruby block reload postgres-exporter svlogd configuration
Running handlers:
Running handlers complete
Chef Client finished, 384/541 resources updated in 04 minutes 07 seconds
gitlab Reconfigured!

# gitlab-ctl restart        # 重启gitlab服务,gitlab是由多种服务组成的,或者 systemctl start gitlab-runsvdir
ok: run: gitaly: (pid 4123) 1s
ok: run: gitlab-monitor: (pid 4133) 0s
ok: run: gitlab-workhorse: (pid 4136) 1s
ok: run: logrotate: (pid 4144) 0s
ok: run: nginx: (pid 4151) 1s
ok: run: node-exporter: (pid 4156) 0s
ok: run: postgres-exporter: (pid 4165) 1s	
ok: run: postgresql: (pid 4175) 0s
ok: run: prometheus: (pid 4183) 0s
ok: run: redis: (pid 4187) 0s
ok: run: redis-exporter: (pid 4194) 0s
ok: run: sidekiq: (pid 4199) 0s
ok: run: unicorn: (pid 4208) 0s
            
# 停止gitlab
# gitlab-ctl stop
# systemctl stop gitlab-runsvdir

# 停止gitlab中的单个服务
gitlab-ctl stop nginx
3 访问 http://你的服务器ip,设置root密码,默认管理员登录名是root(之后就可以自己注册一个普通用户名了)

如果遇到 【Whoops, GitLab is taking too much time to respond. Try refreshing the page, or going back and attemp】 就看一下是否有8080占用了gitlab端口

安装汉化补丁,并再次访问

说明:这里如果使用的同样是gitlab10.2.2,下载汉化较慢的话,可以直接下载【gitlab依赖包】

复制代码
1、下载汉化补丁
[root@gitlab ~]# git clone https://gitlab.com/xhang/gitlab.git
[root@gitlab ~]# cd gitlab    
2、查看全部分支版本
[root@gitlab ~]# git branch -a
3、对比版本、生成补丁包
[root@gitlab ~]# git diff remotes/origin/10-2-stable remotes/origin/10-2-stable-zh > /tmp/10.2.2-zh.diff
4、停止服务器
[root@gitlab ~]# gitlab-ctl stop
5、打补丁
[root@gitlab ~]# patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /tmp/10.2.2-zh.diff
6、启动和重新配置
[root@gitlab ~]# gitlab-ctl start
[root@gitlab ~]# gitlab-ctl reconfigure
4.1 如果服务器更换了ip地址,gitlab配置文件也最好更换
复制代码
1. 先修改本地的IP地址
vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.10.100
NETMASK=255.255.255.0
GATEWAY=192.168.10.1

systemctl restart network
2. 修改gitlab.rb,中的WEB页面地址
# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.10.100'

3. 修改gitlab仓库地址
vim /var/opt/gitlab/gitlab-rails/etc/gitlab.yml
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: 192.168.10.100
    port: 80
    https: false
    ......
    email_from: gitlab@192.168.10.100

4. 重启gitlab
gitlab-ctl restar
5 创建项目后是这样的


复制代码
Command line instructions

Git global setup
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"

Create a new repository
git clone http://gitlab.example.com/dev/my-project1.git
cd my-project1
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder
cd existing_folder
git init
git remote add origin http://gitlab.example.com/dev/my-project1.git
git add .
git commit -m "Initial commit"
git push -u origin master

Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin http://gitlab.example.com/dev/my-project1.git
git push -u origin --all
git push -u origin --tags

第二种安装方法:有的系统可能不支持

https://www.cnblogs.com/laobaozi/p/6638334.html

相关推荐
l1t8 分钟前
用split命令恢复被wget -c命令误追加的zip压缩包
linux
随性而行36027 分钟前
微信API接口与AI自动化:开发者的实现思路
运维·服务器·开发语言·人工智能·微信·自动化
辉灰笔记1 小时前
MySQL8 意外关机/误移data目录导致服务启动失败 PID报错/权限报错 修复文档
linux·数据库·mysql·centos
胖兔纸22 小时前
OpenStack 1.7.2 & Ceph 9.2.1 运维命令
运维·ceph·openstack
不会C语言的男孩3 小时前
Docker 在嵌入式设备中的常用玩法
运维·docker·容器
ylscode3 小时前
CVE-2026-31694 漏洞深度分析:Linux 内核 FUSE 组件存在本地提权风险,普通用户可直取 root 权限
linux·运维·服务器
智脑API平台4 小时前
Codex CLI 怎么用 .env 配置 API Key?本地项目和自动化脚本接入教程
运维·自动化
无足鸟ICT4 小时前
【RHCA+】bash命令
linux·开发语言·bash
weixin_307779134 小时前
Linux下Docker Compose里运行的MySQL数据库故障诊断Shell脚本
linux·运维·mysql·docker·自动化
小生不才yz4 小时前
Shell脚本精读 · S14-02 | 脚本模板:从 20 行工具到可维护项目
linux