在CentOS 7上安装GitLab

在vm中试了下搭建git代码托管服务gitlab,公司现在用的也是gitlab,觉得挺好用的就搜了下自己搭建了一个

先上一下gitlab截图,能用markdown写东西真的很爽啊,为啥wordpress博客对markdown的支持不好捏(所以看到我的文章有点乱请小喷)


下面把步骤写一下:

安装必要的包

  1. sudo yum install curl openssh-server

    安装curl 和 openssh-server

  2. sudo systemctl enable sshd

    systemctlchkconfigservice命令的合体,上面这个命令是设置sshd开机自启

  3. sudo systemctl start sshd

    启动 sshd 服务

  4. sudo yum install postfix

    安装 postfix 邮件服务器

  5. sudo systemctl enable postfix

    设置 postfix 开机自启动

  6. sudo systemctl start postfix

    启动 postfix 服务

  7. sudo firewall-cmd --permanent --add-service=http

    防火墙永久开启 http 服务

  8. sudo systemctl reload firewalld

    防火墙设定生效

下载rpm包

进入 清华的镜像:http://mirror.tuna.tsinghua.edu.cn/gitlab-ce/

选择一个包下载下来,我下载的包名为:gitlab-ce-8.3.1-ce.1.el7.x86_64.rpm

chmod +x gitlab-ce-8.3.1-ce.1.el7.x86_64.rpm

rpm -i gitlab-ce-8.3.1-ce.1.el7.x86_64.rpm

配置

打开配置文件vim /etc/gitlab/gitlab.rb

  1. 配置仓库URL地址

    修改配置项:external_url修改为你的gitlab的域名或IP地址

    注:此处必改,否则生成的仓库地址是http://localhost/XXXX/XXX.git

  2. 配置仓库保存位置

    修改配置项:git_data_dir认为 /var/opt/gitlab/git-data

  3. 让配置生效

sudo gitlab-ctl reconfigure

在浏览器访问

http://192.168.3.211/

认的用户名密码为:root/5iveL!fe

常见问题
官方文档地址: http://doc.gitlab.com/ce/

修改监听端口

  1. Gitlab 安装包自带Nginx,要使用 80 端口对外服务,同时 Unicorn 要使用 8080 端口对内服务
  2. 但在我们的服务器上这两个端口都已经被占用了
  3. 因此,解决办法是:修改 Nginx认端口为 9000,指定 Unicorn 的认端口为 9001,修改 Gitlab-shell 的认端口为 9001

修改这个文件
sudo vim /etc/gitlab/gitlab.rb

external_url 'http://ip_adress:9000'
unicorn['port'] = 9001


配置生效后具体会修改文件

  • Nginx: /var/opt/gitlab/Nginx/conf/gitlab-http.conf
  • Unicorn: /var/opt/gitlab/gitlab-rails/etc/unicorn.rb
  • Gitlab-shell: /var/opt/gitlab/gitlab-shell/config.yml
重新加载使其生效

# sudo gitlab-ctl reconfigure

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native