Gitlab部署
Clone地址和端口修改
- 修改gitlab上的ssh/http的克隆地址
当集成好了后他的地址是一个默认生成的东西(巨他妈难看也难记),我们需要将它改成我们所熟悉的域名或者是ip地址。
注意:这里的修改只是单纯的url显示修改,并不是web访问的修改
1.进入系统根目录后
2.执行-> cd /opt/gitlab/embedded/service/gitlab-rails/config
3.执行编辑-> vim gitlab.yml
## GitLab settings
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: 120.79.50.233 # 填写我们需要显示的地址,也可以是域名
port: 80 # 填写我们需要显示的端口
https: false # 是否显示https
4.重启gitlab-> gitlab-ctl restart
5.如果立马刷新浏览器会报505错误,别担心,在等几十秒钟在重新刷新就好。
- 修改gitlab端口号
因为gitlab默认使用的是80端口,ip和域名的直接默认访问就是80端口,一般我们需要80端口去做点别的事情,所以就会产生冲突,这个时候就需要去修改gitlab的端口号,为真正需要用到的80端口服务让一让路。
1.修改gitlab.rb文件
>1.进入系统根目录
>2.执行-> cd etc/gitlab/
>3.执行-> vim 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://tingxunsun.com' #这是gitlab网站访问的地址设置(域名、ip都OK的)
#找的到就找,找不到就自己写一条这个,因为里面文本太长我懒得看,直接开头处加一句就好了
nginx['listen_port'] = 82 # 自己要用的端口
2.继续修改gitlab-http.conf文件
>1.进入系统根目录
>2.执行-> cd var/opt/gitlab/nginx/conf/
>3.执行-> vim gitlab-http.conf
server {
listen *:82; # 设置Nginx的真实监听端口
server_name tingxunsun.com;
3.继续修改config.yml文件,为了报错提交不出错GitLab: Failed to authorize your Git request: internal API unreachable .
>1.执行-> cd /var/opt/gitlab/gitlab-shell
>2.执行-> vim config.yml
# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.
# GitLab user. git by default
user: git
# Url to gitlab instance. Used for api calls. Should end with a slash.
gitlab_url: "http://127.0.0.1:82" # 端口更改成我们的82端口
4.这一步非常关键:上面说的端口只是临时想起的,而非在服务器已经存在的,所以我们需要
在服务器添加安全组规则,增加82端口服务,并且设置允许ip访问
5.重启gitlab-> gitlab-ctl restart
6.刷新浏览器-> http://tingxunsun.com:82 # 用自己设置的地址去刷新
7.这时候我们发现克隆地址里端口怎么是80呢,其实压根不影响。
如果为了统一,我们返回克隆地址修改,将端口显示改成82,在重启gitlab,在刷新浏览器就好了。
- gitlab的一些命令
gitlab-ctl reconfigure # 重新加载配置文件 gitlab-ctl status # 查看命令 gitlab-ctl tail unicorn # 查看gitlab的unicorn组件状态