gitLab服务器部署
一、Linux环境准备
# 关闭 SELinux
setenforce 0
# 关闭防火墙
systemctl stop firewalld.service
安装最新的git
yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
yum install git
二、Gitlab Server部署
- 安装依赖
yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python
- 开启postfix
systemctl start postfix
systemctl enable postfix
- 添加yum源
vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
gpgcheck=0
Enabled=1
Gpgkey=https://packages.gitlab.com/gpg.key
- 安装gitlab
# 自动安装gitlab最新版
yum -y install gitlab-ce
# 查看版本
head -1 /opt/gitlab/version-manifest.txt
- 配置登陆链接
vim /etc/gitlab/gitlab.rb
***
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url 'http://10.20.151.999' # 没有域名,可以设置为本机IP地址
***
# 初始化
gitlab-ctl reconfigure
# 设置HTTPS方式
letsencrypt['enable'] = true
# 联系人的电子邮件地址
letsencrypt['contact_emails'] = ['caryyu@qq.com']
- Gitlab常用管理命令
gitlab-ctl start # 启动所有 gitlab 组件;
gitlab-ctl stop # 停止所有 gitlab 组件;
gitlab-ctl restart # 重启所有 gitlab 组件;
gitlab-ctl status # 查看服务状态;
gitlab-ctl reconfigure # 启动服务;
vim /etc/gitlab/gitlab.rb # 修改默认的配置文件;
gitlab-ctl tail # 查看日志;
- 邮件
gitlab-rails console
Loading production environment (Rails 4.2.10)
irb(main):001:0> Notify.test_email('xxxx@163.com', 'sz2002', 'test').deliver_now
- 查看初始化密码
cat /etc/gitlab/initial_root_password
- 浏览器访问gitLab地址
root + 初始化密码登录
访问配置的 IP 或 域名
- 签证问题?
Cannot issue for “8.130.70.200”: The ACME server can not issue a certificate for an IP address
vim paugram.com/paugram.com.conf
安装gitlab runner
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el7/gitlab-runner-16.6.0-1.x86_64.rpm
rpm -ivh gitlab-runner-16.6.0-1.x86_64.rpm
构建/Runner里/注册上runner
替换 yum源
$ sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
/home/gitlab-runner/builds/Uon4FMfo/0/smart-summary/smart-summary-server/.git/
runner 设置root权限
$ groups gitlab-runner
> gitlab-runner : gitlab-runner
$ sudo usermod -a -G root gitlab-runner
$ sudo groups gitlab-runner
> gitlab-runner : gitlab-runner root
重制root密码
gitlab-rails console -e production
user = User.find_by_username('<username>') # 用正确的用户名替换 <username>
user.password = '<NEW_PASSWORD>' # 用新密码替换 <NEW_PASSWORD>
user.password_confirmation = '<NEW_PASSWORD>' # 用新密码替换 <NEW_PASSWORD>
user.save!
quite #退出