在Linux上自定义GitLab配置可以通过以下步骤完成:
对于Ubuntu/Debian系统,使用以下命令安装依赖包:
sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
对于CentOS系统,使用以下命令安装依赖包:
sudo yum install -y curl policycoreutils-python openssh-server postfix
使用官方安装包(适用于Omnibus安装):
curl https://packages.gitlab.com/gpg.key | sudo apt-key add -
sudo bash -c 'echo "deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/gitlab.list'
sudo apt-get update
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo yum install gitlab-ce
使用官方提供的Omnibus安装包来安装GitLab CE(社区版):
sudo EXTERNAL_URL="http://your_server_ip" apt-get install gitlab-ce
将http://your_server_ip替换为你的服务器IP地址或域名。
/etc/gitlab/gitlab.rb 文件,设置外部URL:sudo vi /etc/gitlab/gitlab.rb
找到并修改以下行:
external_url 'http://your_server_ip'
保存并退出编辑器。
sudo gitlab-rails console production
在控制台中运行以下命令来设置邮件服务:
user User.find_by_username('root')
user.password 'your_email@example.com'
user.password_confirmation 'your_email@example.com'
user.save!
退出控制台。
sudo gitlab-ctl reconfigure
配置完成后,启动GitLab服务:
sudo gitlab-ctl start
sudo systemctl enable gitlab
在浏览器中输入设置的外部URL,按照提示设置管理员密码并登录。
以上步骤是在Linux上配置GitLab的基本流程。请注意,具体的命令和配置可能会因Linux发行版和GitLab版本的不同而有所差异。建议参考GitLab的官方文档以获取最准确的安装指南。