gitlab服务器ubuntu16环境下搭建

本文详细介绍了在Ubuntu16.04上安装GitLab的步骤,包括下载安装脚本、初始化管理员账号、创建GitLab项目、设置外部URL、关闭防火墙以及禁用和启用GitLab开机启动。此外,还解决了遇到的不能登录服务器的问题。通过这些步骤,你可以成功在本地搭建并管理一个GitLab服务器。

1.ubuntu16安装gitlab

首先参考
在ubuntu16上搭建gitlab(实测可用)

download adrr

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt-get install gitlab-ce
sudo gitlab-ctl reconfigure
//检查GitLab是否安装好并且已经正确运行,输入下面的命令(查看gitlab的状态)
sudo gitlab-ctl status

2.管理员账号初始化

完成后想登录http://127.0.0.1/ 需要账号和密码登录,注册一个后登录报
Your account is pending approval from your GitLab administrator and hence blocked
错误,需要管理员账号初始化.
账号初始化参考下面博客
https://blog.csdn.net/hnmpf/article/details/80518460
初始化好后输入账号和密码就可以登录进去了。

sudo gitlab-rails console
在irb(main):001:0> 后面通过 u=User.where(id:1).first 来查找与切换账号(User.all 可以查看所有用户)
通过u.password='12345678'设置密码为12345678(这里的密码看自己喜欢):
通过u.password_confirmation='12345678' 再次确认密码
通过 u.save!进行保存(切记切记 后面的 ! return u.save!

3.登录好后需要新建一个gitlab工程

参考下面的链接
https://blog.csdn.net/zerokkqq/article/details/79728527
新建一个工程后会自动进入教程教怎么新建一个工程的

Command line instructions
You can also upload existing files from your computer using the instructions below.
Git global setup
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
Create a new repository
git clone http://gitlab.example.com/root/helloworld.git
cd helloworld
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

没有安装git 的话先sudo apt install git
安装git

4.如何在别的电脑上用浏览器访问gitlab服务器

局域网访问gitlab服务器的话非常简单。只需要配置两项就能达到用浏览器访问gitlab服务器的目的了。

4.1 查看服务器局域网ip 地址并且修改配置文件gitlab.rb

ifconfig

发现服务器ip地址为192.168.20.129

配置文件gitlab.rb

sudo vim /etc/gitlab/gitlab.rb

修改external_url为服务器ip地址

external_url 'http://192.168.1.100'

保存后重新加载配置文件

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

在另外一台电脑的浏览器输入http://192.168.1.100,提示防火墙没有关闭。

4.2关闭服务器防火墙

首先要安装firewalld

sudo apt install firewalld
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload
 
或者
关闭防火墙
sudo systemctl stop firewalld.service #停止firewall
sudo systemctl disable firewalld.service #禁止firewall开机启动

在另外一台电脑的浏览器输入http://192.168.20.129,发现可以登录访问了。

samba install

sudo apt-get install samba 
sudo apt-get install smbclient  
vim /etc/samba/smb.conf   
[share]  
    path = /home/gaojs/work 
    valid users = share
    available = yes  
    browseable = yes  
    writable = yes  
    public = no  
sudo useradd share 
sudo smbpasswd -a share 
sudo service smbd restart
smb://192.168.1.100/share

https://blog.csdn.net/gaojinshan/article/details/78226357

5.禁止gitlab开机启动

5.1暂时关闭关闭gitlab 服务器

暂时关闭gitlab 服务器使用用下面命令

sudo gitlab-ctl stop

5.2永久开机关闭gitlab 服务器自己启动

1.开机禁止gitlab服务自己启动输入下面命令

sudo systemctl stop gitlab-runsvdir.service
sudo systemctl disable gitlab-runsvdir.service

成功禁止后有下面提示

Removed symlink /etc/systemd/system/multi-user.target.wants/gitlab-runsvdir.service.

2.检测是否成功

systemctl status gitlab-runsvdir.service

发现会有下面的提示

 gitlab-runsvdir.service - GitLab Runit supervision process
   Loaded: loaded (/usr/lib/systemd/system/gitlab-runsvdir.service; disabled; ve
   Active: inactive (dead)

5.禁止gitlab开机启动后让gitlab重新开机启动

如果下次想让其开机启动就输入下面的命令

sudo systemctl enable gitlab-runsvdir.service

用下面的脚本发现开机gitlab就启动了

systemctl list-unit-files --type=service |grep enabled
systemctl list-unit-files --type=service |grep gitlab

6.其他

1.不能登录进服务器,执行
sudo gitlab-ctl status
报下面错误
fail: alertmanager: runsv not running

解决
step1:sudo systemctl start gitlab-runsvdir
step2:sudo gitlab-ctl restart
https://blog.csdn.net/qiankunyijian00/article/details/123093846
但是sudo systemctl start gitlab-runsvdir会卡住,解决方法
gitlab 不能启动 runsv not running

参考
https://blog.csdn.net/Amourtani/article/details/103704602
https://www.cnblogs.com/zhujingzhi/p/9703457.html
https://zhuanlan.zhihu.com/p/45336481

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

火星机器人life

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值