1. 安装并配置依赖, 打开防火墙 HTTP,SSH 链接
- yum install -y curl policycoreutils-python openssh-server
- systemctl enable sshd
- systemctl start sshd
- firewall-cmd --permanent --add-service=http
- systemctl reload firewalld
注: 对于防火墙直接关闭内网防火墙即可, 服务器内存至少 4G
2. 安装 Postfix 发信服务器
- yum install postfix
- systemctl enable postfix
- systemctl start postfix
错误: Job for postfix.service failed because the control process exited with error code. See "systemctl st
解决: 修改 /etc/postfix/main.cf 的设置
- inet_protocols = ipv4
- inet_interfaces = all
3. 安装 gitLab
下载最新 rpm 安装: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
rpm -i gitlab-ce-10.6.4-ce.0.el7.x86_64.rpm #安装
或镜像安装:
- curl -sS http://packages.gitlab.com.cn/install/gitlab-ce/script.rpm.sh | sudo bash
- yum install gitlab-ce
4. 修改域名:/etc/gitlab/gitlab.rb 文件
external_url 'http://gitlab.mag998.com/' #需添加域名解析
5. 启动 gitLab
- gitlab-ctl reconfigure #重置初始化
- gitlab-ctl restart #启动
报错 ENOMEM: 内存至少 4G,500 等错误, 增加内存
- free -m #查看 swap 分区大小
- mkdir /swapfile
- cd /swapfile
- sudo dd if=/dev/zero of=swap bs=1024 count=5000000 #修改 count,5G 的大小
- mkswap -f swap #转化为 swap 文件
- swapon swap #激活 swap 文件
- free -m #查看大小
- swapoff swap #卸载 swap 分区
- /swapfile/swapfile none swap defaults 0 0 #写入 / etc/fstab 文件
访问报错 502:chmod -R 755 /var/log/gitlab
注: 关闭原有 nginx 和 tomcat, 因为他们会占用 80,8080 端口, 加 swap 分区后最好重启服务器
6. 正常访问后, 修改 nginx 等的端口配置
1. /etc/gitlab/gitlab.rb 文件
- unicorn['port'] = 8081
- nginx['listen_port'] = 82
- gitlab_rails['smtp_enable'] = false #postfix 和 smtp 只能用一个
2. /var/opt/gitlab/gitlab-rails/etc/unicorn.rb 文件
listen "127.0.0.1:8081", :tcp_nopush => true
3. /var/opt/gitlab/nginx/conf/gitlab-http.conf 文件
listen *:82;
4. /var/opt/gitlab/gitlab-shell/config.yml 文件
gitlab_url: "http://127.0.0.1:8081"
5. 重置 / 重启
- gitlab-ctl reconfigure
- gitlab-ctl restart
7. 原来的 nginx 配置均衡代理:
- #gitlab server=======start
- upstream gitlab {
- server 127.0.0.1:8081;
- }
- server {
- listen 80;
- server_name gitlab.mag998.com;
- location /{
- client_max_body_size 50m;
- proxy_redirect off;
- proxy_set_header Host $host;
- proxy_set_header X-Real_IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_pass http://gitlab;
- index index.html index.htm;
- }
- }
- #gitlab end============
8. 常用命令
gitlab-ctl start|stop|status|restart
来源: http://www.bubuko.com/infodetail-2572384.html