大家早上好呀,又到了周末了,心情很舒服。摸鱼了一上午,想要写点东西。今天给大家带来的是,git和GitLab的安装。
话不多说,开始吧
1、创建git文件夹
[root@VM-4-12-centos git]# pwd /opt/git
2、下载git,yum配置的镜像库有git,直接下载
[root@VM-4-12-centos git]# yum -y install git
3、安装git核心依赖
[root@VM-4-12-centos git]# yum -y install git-core gitweb
3A、检查一下,没有问题
[root@VM-4-12-centos git]# which git /usr/bin/git [root@VM-4-12-centos git]# git --version git version 2.27.0
5、新建git用户,密码是git
[root@VM-4-12-centos git]# useradd git [root@VM-4-12-centos git]# passwd git Changing password for user git. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully.
6、初始化一个git项目
[root@VM-4-12-centos git]# git init demo.git Initialized empty Git repository in /opt/git/demo.git/.git/ [root@VM-4-12-centos git]# ll total 4 drwxr-xr-x 3 root root 4096 May 14 11:49 demo.git
7、修改git文件夹下的权限,给到git用户
修改前:
[root@VM-4-12-centos git]# chown -R git:git demo.git/
修改后:
8、切换到git用户,后面是向git推送数据,这里就不演示了
[root@VM-4-12-centos git]# su - git
-------------------------------------------------------------------------------------------------------------------------------------------------------->
9、接下来是GitLab的安装,首先安装环境依赖
[git@VM-4-12-centos git]$ su - root [root@VM-4-12-centos git]# yum -y install python3 [root@VM-4-12-centos git]# yum -y install curl openssh-server openssh-clients postfix cronie python3-policycoreutils
10、下载gitlab安装包,注意:下载ce社区版本,不要下载ee收费版,另外,这个镜像是国内清华大学官方的,大家可以收藏一下,清华镜像网站
[root@VM-4-12-centos git]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/gitlab-ce-14.9.4-ce.0.el8.x86_64.rpm
11、下载安装包时间有点久,需要耐心等待
[root@VM-4-12-centos git]# ll total 1017072 drwxr-xr-x 3 git git 4096 May 14 11:49 demo.git -rw-r--r-- 1 root root 1041472278 May 3 05:22 gitlab-ce-14.9.4-ce.0.el8.x86_64.rpm
12、安装gitlab,出现了如下提示,说明安装完成
[root@VM-4-12-centos git]# rpm -i gitlab-ce-14.9.4-ce.0.el8.x86_64.rpm
13、然后我们需要提供对外访问,external_url添加你的ip地址,然后需要修改gitlab配置参数,官方默认的参数配置太高,一般的服务器会吃90%的内存,一定要修改!!
[root@VM-4-12-centos git]# vim /etc/gitlab/gitlab.rb
##! Note: During installation/upgrades, the value of the environment variable ##! EXTERNAL_URL will be used to populate/replace this value. ##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP ##! address from AWS. For more details, see: ##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html external_url 'http://101.35.245.191:9000' postgresql['shared_buffers'] = "128MB" puma['worker_timeout'] = 30 sidekiq['max_concurrency'] = 10 patroni['postgresql']['max_worker_processes'] = 1 patroni['postgresql']['max_connections'] = 10
14、初始化,启动gitlab,默认是80端口,我们修改成9000端口
[root@VM-4-12-centos git]# gitlab-ctl reconfigure
15、访问 http://101.35.245.191:9000
[root@tencent02 git]# netstat -ntlp tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 356763/nginx: maste
16、然后我们切到服务器,查看gitlab初始密码
[root@VM-4-2-centos gitlab]# cd /etc/gitlab/ [root@VM-4-2-centos gitlab]# cat initial_root_password
17、用初始密码登录,然后修改初始密码,它默认只保存24小时
18、修改密码以后,为了安全性,我们需要禁止用户注册,正常开发应该有开发组长使用root账户,在界面新开一个用户
19、创建一个项目组,因为一个公司有不同的项目组
20、然后项目经理创建一个用户,给到我们的开发人员
21、创建一个项目,test,然后将tom加入到项目开发
22、最后,就默默的说一句,屏幕前的各位大帅逼,还有大漂亮,看到这里,麻烦给老哥一个点赞、关注、收藏三连好吗,你的支持是老哥更新最大的动力,谢谢!



