欢迎光临高端网站建设公司网站,我们具有丰富的经验,深受客户信赖!

高端网站建设公司

专业品牌网站建设开发,企业高端网站设计价格

1、部署企业级开源仓库gitlab服务器

作者:jcmp      发布时间:2021-04-27      浏览量:0
GitLab 是一个用于仓库管理系统的开

GitLab 是一个用于仓库管理系统的开源项目。 1.安装配置gitlab依赖项 SMT服务、http 和ssh服务端口防火墙开放,测试时最好把防火墙关闭 安装相关依赖,并设置开机自启动。

# yum install -y curl policycoreutils openssh-server openssh-clients postfix。

一、yum方式安装

# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash # yum install gitlab-ce -y。

也可以直接下载gitlab-ce-xxxx.rpm后本地安装(推荐) 下载地址: https://packages.gitlab.com/gitlab/gitlab-ce。

# yum localinstall -y gitlab-ce-xxx.rpm。

3.配置并启动github服务,如果配置文件发生更改需要重新执行此命令:

二、gitlab-ctl reconfigure

* template[/var/opt/gitlab/postgres-exporter/queries.yaml] action create (up to date)Recipe: * service[grafana] action nothing (skipped due to action :nothing)Recipe: gitlab::grafana_disable * runit_service[grafana] action disable * ruby_block[disable grafana] action run (skipped due to only_if) (up to date)Recipe: gitlab::deprecate-skip-auto-migrations * file[/etc/gitlab/skip-auto-reconfigure] action create (skipped due to only_if) * ruby_block[skip-auto-migrations deprecation] action run (skipped due to only_if)Recipe: * service[unicorn] action restart - restart service service[unicorn]Running handlers:Running handlers completeChef Client finished, 10/640 resources updated in 27 secondsgitlab Reconfigured!

查看状态

# gitlab-ctl status

查看nginx日志:

==> /var/log/gitlab/nginx/gitlab_error.log <====> /var/log/gitlab/nginx/access.log <====> /var/log/gitlab/nginx/gitlab_access.log <==192.168.56.1 - - [30/Apr/2019:11:46:15 +0800] "GET /liuzhousheng/web-django HTTP/1.1" 200 16066 "http://192.168.56.3/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36"192.168.56.1 - - [30/Apr/2019:11:46:16 +0800] "GET /assets/favicon-7901bd695fb93edb07975966062049829afb56cf11511236e61bcf425070e36e.png HTTP/1.1" 200 1611 "http://192.168.56.3/liuzhousheng/web-django" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36"192.168.56.1 - - [30/Apr/2019:11:46:18 +0800] "GET /liuzhousheng/web-django/commits/master/signatures HTTP/1.1" 200 17 "http://192.168.56.3/liuzhousheng/web-django" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36"192.168.56.1 - - [30/Apr/2019:11:46:19 +0800] "GET /liuzhousheng/web-django/blob/master/README.md?format=json&viewer=rich HTTP/1.1" 304 0 "http://192.168.56.3/liuzhousheng/web-django" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36"192.168.56.1 - - [30/Apr/2019:11:46:20 +0800] "GET /liuzhousheng/web-django/refs/master/logs_tree/?format=js HTTP/1.1" 304 0 "http://192.168.56.3/liuzhousheng/web-django" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36"

4.访问web界面 如打开以后是502的界面,需要检查80和8080端口是否被占用,另外增加内存,然后重新执行3步骤,首次登录得修改密码 4.1关闭登录页面的注册功能,否则可能导致信息泄露,使用admin 登录。

最后点下方的save 退出登录,验证是否还有注册的功能:

重新选择创建的用户点击Edit设置密码

4.4创建项目:

为项目创建一个web页面: Project–组名/项目名–add a README—

测试客户端更新名提交代码,安装git客户端:

# yum install git -y

5.使用git更新及提交代码:

5.1 克隆代码:

# mkdir /data/appscd /data/apps/

①http方式克隆

# git clone http://192.168.56.3/liuzhousheng/web-django.git正克隆到 'web-django'...Username for 'http://192.168.56.3': liuzhoushengPassword for 'http://liuzhousheng@192.168.56.3':remote: Enumerating objects: 27, done.remote: Counting objects: 100% (27/27), done.remote: Compressing objects: 100% (19/19), done.remote: Total 27 (delta 2), reused 27 (delta 2)Unpacking objects: 100% (27/27), done.[root@localhost apps]# ll总用量 0drwxr-xr-x. 3 root root 50 4月 30 12:21 web-django。

②通过ssh-key方式克隆 将客户端user_00用户的公钥拷贝到gitlab服务器的web端项目ssh-key中。

[user_00@localhost ~]$ cat .ssh/id_rsa.pubssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHSkr5zTWobDcIUM6mFKDqFK6jO0CBlzD5qaOazO6WeKrJIlHtIaFZW4yAezWp9Cc8ZT0FCUaXHaOk39RKxIJGAuyi8kOpYM07/3NisRhukpu2HTTQKhAM3UpyQAjd+2w+Sw6Dl99YNeq0QVGn+2BGDCjaip4A6jNVpG601q3ztMr/ujtTXT0ulZcoy4xgtULpN66/Fu3YKUO1KuK6a6gxfdGyB9VIbrzS/ftdtsLvBD0TPisLbxN//ydwtvtJ1c1hqJtwob97F5v1Hu7rMEBjTVk3WwJ65eE0cey/L/0oPSePQHXJJI9geSwcHZdkWu1Di035SVa7E402ia6FgJYJ user_00@192.168.56.4。

克隆代码

[user_00@localhost apps]$ git clone git@192.168.56.3:liuzhousheng/web-django.gitCloning into 'web-django'...remote: Enumerating objects: 27, done.remote: Counting objects: 100% (27/27), done.remote: Compressing objects: 100% (19/19), done.remote: Total 27 (delta 2), reused 27 (delta 2)Receiving objects: 100% (27/27), done.Resolving deltas: 100% (2/2), done.[user_00@localhost apps]$ tree ././└── web-django ├── README.md └── test.py。

$ cd /data/apps/web-django$ git branch dev #本地创建一个分支$ git checkout dev #切换本地分支$ git push origin dev #将本地分支发布到github$ vim index.html #更新一下代码

my first web project

# git add index.html #提交更改到本地版本库# git commit -m "second commit" #提交到git仓库# git push -u origin dev #提交到一个分支。

提交成功信息如下: 如果提交代码报错,提示没有权限提交,请检查提交的用户是否有对组的提交权限:

二:git常用命令汇总:

配置gitlab为http方式: 将 http://web01/liuzhousheng/web-django.git 改为 http://192.168.56.3/liuzhousheng/web-django.git。

步骤:

# vim /etc/gitlab/gitlab.rbexternal_url 'http://web01'改为external_url 'http://192.168.56.3'

重新配置服务生效

# gitlab-ctl reconfigure

新建项目和历史项目都会变成IP了http://192.168.56.3。