一、GitLab安装1.1准备工作1.1.1关闭防火墙关闭防火墙命令:iptables-F查看防火墙命令:iptables-L1.1.2关闭SELinuxsed-i's/SELINUX=enforcing/SELINUX=disabled/g'/etc/selinux/configsetenforce01.1.3关闭NetworkManagersystemctldisableNetworkManager1.1.4安装GetLab依赖包yuminstall-ycurlpolicycoreutilspolicycoreutils-pythonopenssh-serveropenssh-clientspostfix然后执行:systemctlrestartpostfix如果发生以下错误:postfix.service的作业失败,因为控制进程退出并显示错误代码。有关详细信息,请参阅“systemctlstatuspostfix.service”和“journalctl-xe”。修改vim/etc/postfix/main.cf如下内容inet_protocols=ipv4inet_interfaces=all执行命令:systemctlenablepostfix查看是否启动:ps-ef|greppostfix1.1.5启动sshd查看sshd是否启动:ps-ef|grepsshd如果没有启动,执行以下命令。执行命令:systemctlenablesshd执行命令:systemctlstartsshd1.2GitLab下载1.2.1下载地址wgethttps://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.5。3-ce.0.el7.x86_64.rpm1.2.2解压rpm-ivhgitlab-ce-11.5.3-ce.0.el7.x86_64.rpm2.GitLab配置2.1配置文件路径vim/etc/gitlab/gitlab。rb文件2.2配置域名地址,填写域名地址2.3修改Git库默认端口号SSH链接2.4邮件服务器配置本示例参数配置为阿里云企业邮箱的配置2.5修改默认端口号Git库HTTP链接2.5.1文件路径vim/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml2.5.2修改后重启:gitlab-ctlrestart注意:此操作只能在GitLab之后执行开始修改端口,否则之前的修改会被配置文件覆盖!!!3、GitLab命令3.1GitLab启动配置文件配置好后,先加载配置,第一次加载会比较慢。加载配置命令:gitlab-ctlreconfigure加载配置后,启动GitLab。启动Gitlab命令:gitlab-ctlstart第一次打开Gitlab网站会设置root账号密码。3.2GitLab加载配置文件常用命令命令:gitlab-ctlreconfigure启动GitLab命令:gitlab-ctlstart重启GitLab命令:gitlab-ctlrestart停止GitLab命令:gitlab-ctlstop查看GitLab服务状态:gitlab-ctlstatus查看GitLab版本number:head-1/opt/gitlab/version-manifest.txt3.3GitLab日志查看日志命令:gitlab-ctltail4.GitLab账号配置SSHkey4.1本地密钥生成密钥生成命令:ssh-keygen-trsa-C"your.email@example.com"-b4096说明:-b4096:b是bit的缩写4096是key的长度,最小768位,默认2048位4.2查看本地keyid_rsa是私钥,id_rsa.pub为公钥,Linux和Windows文件路径为:Linux:Windows:4.3配置返回GitLab项目库的密钥,复制git库的SSH链接。使用gitclone命令通过ssh下载项目。五、GitLab汉化5.1下载最新的汉化包gitclonehttps://gitlab.com/xhang/gitlab.git如果要下载指定版本的汉化包,需要加上版本号。示例:下载11.0.6,命令如下:gitclonehttps://gitlab.com/xhang/gitlab.git-bv11.0.6-zh汉化前停止GitLab,命令:gitlab-ctlstop。5.2汉化文件覆盖cp-r-f./gitlab/*/opt/gitlab/embedded/service/gitlab-rails/这里有一个坑,复制覆盖的时候需要按N多于Y,使用其他方法比较麻烦,在cp前面加个反斜杠搞定\cp-r-f./gitlab/*/opt/gitlab/embedded/service/gitlab-rails/复制后重新加载配置,命令:gitlab-ctlreconfigure,并启动GitLab,命令:gitlab-ctlstart。
