简介官方网站https://about.gitlab.com/GitLab是由GitLablnc.开发使用MIT许可证的基于网络的Git仓库管理工具且具有wiki和ssue跟踪功能。使用Git作为代码管理工具并在此基础上搭建起来的web服务。安装GitLab以CentOS7为例官网教程https://about.gitlab.com/install/安装依赖yum -y install policycoreutils openssh-server openssh-clients postfix设置postfix开机自启并启动postfixsystemctl enable postfix systemctl start postfix下载gitLabrpm离线安装包下载地址Index of gitlab/gitlab-ce/从 https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/ 找一个比较新的版本右键拷贝链接地址然后使用wget下载wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.2.5-ce.0.el7.x86_64.rpm --no-check-certificate安装gitLabrpm -i gitlab-ce-14.2.5-ce.0.el7.x86_64.rpm修改配置文件vi /etc/gitlab/gitlab.rb如下将external_url 设置为具体的ip加端口号external_url http://192.168.195.128:8080配置防火墙可以直接把防火墙关闭systemctl disable firewalld #永久关闭 systemctl stop firewalld #临时关闭重启会恢复开发指定端口查看防火墙已经放开的端口如下表示当前没有端口放开firewall-cmd --list-all防火墙开放上述设置的端口firewall-cmd --zonepublic --add-port8080/tcp --permanent firewall-cmd --reload重新加载gitlab的配置并重新启动gitlabgitlab-ctl reconfigure # 此命令可能需要执行几分钟耐心等待 gitlab-ctl restart如果执行gitlab-ctl reconfigure 报如下错误Running handlers: There was an error running gitlab-ctl reconfigure: ruby_block[authorize Grafana with GitLab] (monitoring::grafana line 101) had an error: Mixlib::ShellOut::CommandTimeout: Command timed out after 600s: Command exceeded allowed execution time, process terminated ---- Begin output of /opt/gitlab/bin/gitlab-rails runner -e production app Doorkeeper::Application.where(redirect_uri: http://192.168.1.210:8080/-/grafana/login/gitlab, name: GitLab Grafana).first_or_create;puts app.uid.concat( ).concat(app.secret); ---- STDOUT: STDERR: ---- End output of /opt/gitlab/bin/gitlab-rails runner -e production app Doorkeeper::Application.where(redirect_uri: http://192.168.1.210:8080/-/grafana/login/gitlab, name: GitLab Grafana).first_or_create;puts app.uid.concat( ).concat(app.secret); ---- Ran /opt/gitlab/bin/gitlab-rails runner -e production app Doorkeeper::Application.where(redirect_uri: http://192.168.1.210:8080/-/grafana/login/gitlab, name: GitLab Grafana).first_or_create;puts app.uid.concat( ).concat(app.secret); returned可以依次执行如下命令gitlab-ctl stop chmod 755 /var/opt/gitlab/postgresql systemctl restart gitlab-runsvdir gitlab-ctl reconfigure或者配置swap分区再执行gitlab-ctl reconfigure 即可分配2G空间sudo dd if/dev/zero of/root/swapfile bs1M count2048制作文件并生效sudo mkswap /root/swapfile sudo swapon /root/swapfile设置开机启动sudo vim /etc/fstab在最后一行加进去/root/swapfile swap swap defaults 0 0最后free -m查看是否生效生效后重新执行gitlab-ctl reconfigure 即可浏览器访问浏览器打开 http://192.168.195.128:8080/如果出现502 Whoops, GitLab is taking too much time to respond. 的错误则首先检查一下端口是否被占用如下表示8080被占用了需要重新配置访问地址在配置端口时可以先使用netstat -tunlp |grep 8080命令检查端口是否被占用,然后执行gitlab-ctl restart查看root用户默认的密码默认账号为rootcat /etc/gitlab/initial_root_password修改密码依次点击【头像】-【Edit profile】-【password】然后修改密码即可。新密码为1qazWSXIDEA集成GitLab安装GitLab插件打开idea File - Settings - Plugins搜索GitLab Projects 2020配置GitLab打开idea File - Settings - GitLab点击Add New GitLab Server在push代码的时候改为GitLab地址即可GitLab地址http://ip:[port]/root/[project].git例如我在GitLab上创建了一个git_demo库GitLab地址即为http://192.168.195.128:8081/root/git_demo.git在push时添加GitLab地址