Ubuntu 22.04下搭建gitlab服务器
gitlab初始管理员账户名为root,初始密码放在临时文件“/etc/gitlab/initial_root_password”中,这个文件将在首次执行reconfigure的24小时后自动删除,登陆后再自行修改密码即可。在其它机器上可以通过gitlab服务器ip或重定向url到gitlab服务器ip后通过url访问gitlab(此处仅考虑局域网内使用的情况)。修改external_url,设置
1.安装依赖
sudo apt update
sudo apt-get upgrade
sudo apt install build-essential ca-certificates curl file git openssh-server
sudo DEBIAN_PRIORITY=low apt install postfix
安装postfix时会出现一系列界面交互选项,请使用以下设置(我的Ubuntu用户名是flight,主机名是mail.flight.com):
- General type of mail configuration?: Internet Site
- System mail name: flight.com
- Root and postmaster mail recipient: flight
- Other destinations to accept mail for: $myhostname, flight.com,
mail.flight.com, localhost.flight.com, localhost - Force synchronous updates on mail queue?: No
- Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
- Mailbox size limit: 0
- Local address extension character: +
- Internet protocols to use: all
更改主机名可通过如下命令:
hostnamectl --static set-hostname mail.flight.com
重新配置postfix选项可通过如下命令:
sudo dpkg-reconfigure postfix
sudo systemctl reload postfix
2.安装gitlab
下载Ubuntu 22.04对应的gitlab安装包,执行
sudo dpkg -i gitlab-ce_16.1.0-ce.0_amd64.deb
如果出现下面的界面则gitlab安装成功。
执行
sudo gedit /etc/gitlab/gitlab.rb
修改external_url,设置从外部机器访问gitlab的ip或者域名,这里我改为了’http://gitlab.flight.com’。
执行
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
sudo systemctl enable gitlab-runsvdir.service # 启用开机自启动
启动gitlab服务和组件后,在本机可以通过localhost直接访问gitlab。
执行
sudo gedit /etc/hosts
修改/etc/hosts文件,参照external_url,添加如下一行
127.0.0.1 gitlab.flight.com
重定向url后,在本机可以通过external_url访问gitlab。在其它机器上可以通过gitlab服务器ip或重定向url到gitlab服务器ip后通过url访问gitlab(此处仅考虑局域网内使用的情况)。
3.gitlab登陆使用
gitlab初始管理员账户名为root,初始密码放在临时文件“/etc/gitlab/initial_root_password”中,这个文件将在首次执行reconfigure的24小时后自动删除,登陆后再自行修改密码即可。
- 修改gitlab语言
- 修改gitlab注册限制策略
- 生成(ssh-keygen -t rsa)并配置gitlab公钥即可拉取或推送代码
参考
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-on-ubuntu-22-04
https://www.cnblogs.com/whcc/p/15514951.html
更多推荐
所有评论(0)