====== 环境:centos7 ====== **1. 安装依赖软件** yum -y install policycoreutils openssh-server openssh-clients postfix **2.设置postfix开机自启,并启动,postfix支持gitlab发信功能** systemctl enable postfix && systemctl start postfix **3.下载gitlab安装包,然后安装** centos 6系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6 centos 7系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7 我的是centos7,所以我在https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7中找了个gitlab11.6.2版本,建议下载一个比较新的版本,我这里选了一个比较旧的版本仅仅是实验 下载rpm包并安装: wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.6.2-ce.0.el7.x86_64.rpm rpm -i gitlab-ce-11.6.2-ce.0.el7.x86_64.rpm **4.修改gitlab配置文件指定服务器ip和自定义端口:** vim /etc/gitlab/gitlab.rb {{:idste:1008644-20160911113500228-232680032_1_.png?nolink&400|}} 退出并保存 ps:注意这里设置的端口不能被占用,默认是80端口,如果80已经使用,请自定义其它端口,并在防火墙设置开放相对应得端口 开启防火墙端口:iptables -A INPUT -p tcp --dport 80 -j ACCEPT **5.重置并启动GitLab** 执行: gitlab-ctl reconfigure gitlab-ctl restart {{:idste:xt0pk8758_9jc_27_w7g2x.png?nolink&400|}} 提示“ok: run:”表示启动成功 **6.访问 GitLab页面** 如果没有域名,直接输入服务器ip和指定端口进行访问 初始账户: root 密码: 登录的时候进行设置 用户第一次登录修改密码 报错处理: **一.登录502报错** 一般是权限问题,解决方法:chmod -R 755 /var/log/gitlab 如果还不行,请检查你的内存,安装使用GitLab需要至少4GB可用内存(RAM + Swap)! 由于操作系统和其他正在运行的应用也会使用内存, 所以安装GitLab前一定要注意当前服务器至少有4GB的可用内存. 少于4GB内存会出现各种诡异的问题, 而且在使用过程中也经常会出现500错误. **二.gitlab-ctl reconfigure** 报错n itdb: could not obtain information about current user: Permission denied Error executing action `run` on resource 'execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8]' 根据报错信息大概锁定用户的权限问题,安装gitlab-ce会自动添加用户四个用户: gitlab-www:x:497:498::/var/opt/gitlab/nginx:/bin/false git:x:496:497::/var/opt/gitlab:/bin/sh gitlab-redis:x:495:496::/var/opt/gitlab/redis:/bin/nologin gitlab-psql:x:494:495::/var/opt/gitlab/postgresql:/bin/sh google和百度都搜索不到解决方法,既然出错提示到权限问题,那么按照这个方向去查就不会有问题,后来查了文件/etc/passwd的权限是600,给予644权限后,成功解决报错问题 **三. rpm -i gitlab-ce-11.6.2-ce.0.el7.x86_64.rpm** 报错warning: soft/gitlab-ce-11.6.2-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-11.6.2-ce.0.el7.x86_64 解决方法:yum install policycoreutils-python rpm -i gitlab-ce-11.6.2-ce.0.el7.x86_64.rpm ====== 环境:ubuntu16.4 ====== **1.安装依赖包,运行命令** sudo apt-get install curl openssh-server ca-certificates postfix **2.执行完成后,出现邮件配置,选择Internet那一项(不带Smarthost的)** {{:idste:jbu9o_md18axkrgkitan_9l.png?nolink&400|}} **3.利用清华大学的镜像https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/来进行主程序的安装。** 首先信任 GitLab 的 GPG 公钥: curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null **4.利用root用户sudo su ,vim打开文件/etc/apt/sources.list.d/gitlab-ce.list,加入下面一行** deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial main **5.安装gitlab-ce:** sudo apt-get update sudo apt-get install gitlab-ce **6.执行命令** sudo gitlab-ctl reconfigure **7.打开 sshd 和 postfix 服务** service sshd start service postfix start **8.为了使 GitLab 社区版的 Web 界面可以通过网络进行访问,我们需要允许 80 端口通过防火墙,这个端口是 GitLab 社区版的默认端口。为此需要运行下面的命令** sudo iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT **9.检查GitLab是否安装好并且已经正确运行,输入下面的命令** sudo gitlab-ctl status **10.如果得到类似下面的结果,则说明GitLab运行正常** run: gitlab-workhorse: (pid 1148) 884s; run: log: (pid 1132) 884s run: logrotate: (pid 1150) 884s; run: log: (pid 1131) 884s run: nginx: (pid 1144) 884s; run: log: (pid 1129) 884s run: postgresql: (pid 1147) 884s; run: log: (pid 1130) 884s run: redis: (pid 1146) 884s; run: log: (pid 1133) 884s run: sidekiq: (pid 1145) 884s; run: log: (pid 1128) 884s run: unicorn: (pid 1149) 885s; run: log: (pid 1134) 885s **11.在浏览器地址栏中输入:http://ip地址:80,即可访问GitLab的Web页面** 注意端口是否重复