Gitlab基础搭建

首先先把 内存跳到 6G
安装GitLab:
首先要连接网络yum源
[[email protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[[email protected] ~]# sed -i ‘s/$releasever/7/g’ /etc/yum.repos.d/CentOS-Base.repo
[[email protected] ~]# yum clean all
[[email protected] ~]# yum makecache

关闭防火墙以及Linux内核:
[[email protected] ~]# setenforce 0
[[email protected] ~]# systemctl stop firewalld

接下来是安装插件
[[email protected] ~]# yum -y install curl policycoreutils openssh-server openssh-clients postfix
[[email protected] ~]# systemctl enable sshd
[[email protected] ~]# systemctl restart sshd
[[email protected] ~]# systemctl enable postfix
[[email protected] ~]# systemctl start postfix

自己上传rpm包
[[email protected]ost ~]# rpm -ivh gitlab-ce-10.2.3-ce.0.el7.x86_64.rpm

或者用网络上的
[[email protected]~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.2.3-ce.0.el7.x86_64.rpm

[[email protected] ~]# vim /etc/gitlab/gitlab.rb
external_url ‘http://gitlab.example.com’ //13行 讲这行改成
external_url ‘http://192.168.137.101’ //这样

[[email protected] ~]# gitlab-ctl reconfigure \重启 要等很久 不要着急 每修改一个gitlab.rb都要执行一下
结果如下:
Gitlab基础搭建
[[email protected] ~]# gitlab-ctl status //检查状态
Gitlab基础搭建
关闭gitlab:#gitlab-ctl stop
启劢gitlab:#gitlab-ctl start
重启gitlab:#gitlab-ctl restart
查看gitlab:#gitlab-ctl status

用游览器登入GitLab:
http://192.168.137.101/users/sign_in
以下是设置root密码
Gitlab基础搭建
登入进去:
Gitlab基础搭建
登入进去的界面:
Gitlab基础搭建
用自己只带的游览器然后设置成中文
Gitlab基础搭建

接下来是客户端访问结果:
Gitlab基础搭建

Gitlab基础搭建

Gitlab基础搭建
Gitlab基础搭建
Gitlab基础搭建
Gitlab基础搭建
Gitlab基础搭建

Gitlab基础搭建
Gitlab基础搭建
Gitlab基础搭建
Gitlab基础搭建
Gitlab基础搭建

[[email protected] ~]# yum -y install httpd*
[[email protected] ~]# systemctl start httpd
[[email protected] html]# git clone http://192.168.137.101/bdqn.com/web.git

Gitlab基础搭建
用游览器验证一下

Gitlab基础搭建
Gitlab基础搭建

以之前的形式在创建一个内部访问的项目 并且把liangzhongyi这个用户添加进去

添加用户到项目如下:

Gitlab基础搭建
Gitlab基础搭建
Gitlab基础搭建
Gitlab基础搭建

因为之前已经添加过了 所以这是演示

Git客户端:
上面的只是克隆 下面的是Git的用法
一般在新的系统上,我们都需要先配置下自己的Git 工作环境。配置工作只需一次,以后升级时还会沿用现在的配置。第一个要配置的是你个人的用户名称和电子邮件地址。这两条配置很重要,每次Git 提交时都会引用这两条信息,说明是谁提交了更新,所以会随更新内容一起被永久纳入历史记录。git运行的环境变量有点像.bashrc,决定了Git 在各个环节的具体工作方式和行为。这些变量可以存放在以下两个的地方:
1、~/.gitconfig 文件:用户目录下的配置文件只适用亍该用户。若使用git config 时用–global 选项,读写的就是这个文件。
如下:
[[email protected] ~]# git config --global user.name “liangzhongyi”
[[email protected] ~]# git config --global user.email “[email protected]
[[email protected] ~]# cat ~/.gitconfig
[user]
name = liangzhongyi
email = [email protected]

咱们已经设置完了 来验证他的效果
现在gitlab里面添加项目 如下:
Gitlab基础搭建
这里需要验证才能下载:
[[email protected] web1]# git clone http://192.168.137.101/accp.com/web1.git
正克隆到 ‘web1’…
Username for ‘http://192.168.137.101’: liangzhongyi
Password for ‘http://[email protected]’:
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.

然后是上传 我们来看看上传有没有记录:
首先创建一个文件
Gitlab基础搭建

[[email protected] web1]# git add index.jsp
[[email protected] web1]# git commit -m “shang chuan”
[master a0381c0] shang chuan
1 file changed, 1 insertion(+)
create mode 100644 index.jsp
[[email protected] web1]# git push
warning: push.default 未设置,它的默认值将会在 Git 2.0 由 ‘matching’
修改为 ‘simple’。若要不再显示本信息并在其默认值改变后维持当前使用习惯,
进行如下设置:

git config --global push.default matching

若要不再显示本信息并从现在开始采用新的使用习惯,设置:

git config --global push.default simple

参见 ‘git help config’ 并查找 ‘push.default’ 以获取更多信息。
(‘simple’ 模式由 Git 1.7.11 版本引入。如果您有时要使用老版本的 Git,
为保持兼容,请用 ‘current’ 代替 ‘simple’ 模式)

Username for ‘http://192.168.137.101’: liangzhongyi
Password for ‘http://[email protected]’:
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 299 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://192.168.137.101/accp.com/web1.git
faa2c20…a0381c0 master -> master

上面的字是没有错的 如果想要没有 那操作如下:
[[email protected] web1]# git config --global push.default simple
然后再来一遍:
[[email protected] web1]# git push
Username for ‘http://192.168.137.101’: liangzhongyi
这就没有了 因为已经弄过了 所以不用了

测试如下:
Gitlab基础搭建