gitlab安装指南

#!/bin/bash


# 1.修改镜像源
cd /etc/yum.repos.d && \
rm * -rf  && \
cat >epel-7.repo<<EOF
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://mirrors.aliyun.com/epel/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=http://mirrors.aliyun.com/epel/7/$basearch/debug
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0

[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=http://mirrors.aliyun.com/epel/7/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0
EOF 

cat >Centos-7.repo<<EOF
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
EOF 

# 2.安装基本工具包
yum -y install wget vim lrzsz curl net-tools telnet git patch && \

# 3.安装依赖包
yum -y install curl policycoreutils openssh-server openssh-clients postfix  && \

# 4.启动相关服务
systemctl enable sshd && \
systemctl start sshd && \
systemctl enable postfix && \
systemctl start postfix && \
iptables -F && \
# 若打开防火墙
firewall-cmd --permanent --add-service=http && \
systemctl reload firewalld && \
# 若选择永久关闭
systemctl stop firewalld && \
systemctl disable firewalld && \

# 5.配置清华源镜像仓库
cd /etc/yum.repos.d && \
cat >gitlab-ce.repo<<EOF
[gitlab-ce] 
name=gitlab-ce 
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7 
repo_gpgcheck=0 
gpgcheck=0 
enabled=1
EOF

# 6.安装gitlab版本包
# https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.2.3-ce.0.el7.x86_64.rpm
# 这里最好提前下载好对应版本的rpm包文件并传到服务器
yum -y install /root/software/gitlab-ce-10.2.3-ce.0.el7.x86_64.rpm && \
rpm -qa |grep gitlab-ce && \

# 7.修改环境变量
echo "alias vi='vim'">>/etc/profile && \
echo "alias rm='rm -f'">>/etc/profile && \
source  /etc/profile && \

# 8.修改域名为实际IP地址,便于实际使用
sed -i 's#http://gitlab.example.com#http://192.168.216.107#' /etc/gitlab/gitlab.rb && \

# 9.重新加载下配置
gitlab-ctl reconfigure && \
gitlab-ctl status 

# 10.设置管理界面管理员的root密码
# root/12345678

# 11.取消登录页面的注册按钮
# Admin area 
# Setting
# Sign-up enabled (去掉对勾)
# Save

# 12.汉化gitlab的web页面
# git clone https://gitlab.com/xhang/gitlab.git
gitlab-ctl stop && \
cd /root/software && \
tar xzvf gitlab-patch-zh.tat.gz && \
cd gitlab && \
git diff v10.2.3 v10.2.3-zh > ../10.2.3-zh.diff && \
patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /root/software/10.2.3-zh.diff && \
gitlab-ctl restart 




# 使用gitlab
# 创建普通用户
# 创建用户组

# 创建项目
# 全局配置
git config --global user.name "devops"
git config --global user.email "kevinfreeman_007@163.com"
# 创建新版本库
git clone git@192.168.216.107:devops/Java.git
cd Java
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master


# git 常用命令
# git config --global user.name “name“ #设置全局用户名
# git config --global user.email mail #设置全局邮箱
# git config --global --list #列出用户全局设置
# git add index.html #添加文件到暂存区
# git commit -m “描述内容“ #提交文件到工作区
# git status #查看工作区的状态
# git push #提交代码到 git 服务器上
# git pull #获取代码到本地
# git log #查看操作日志
# vim .gitignore #定义忽略文件
# git reset --hard HEAD^ #git 版本回滚, HEAD 为当前版本,加一个^为上一个,^^为上上一个版本
# git reflog # #获取每次提交的 ID,可以使用--hard 根据提交的 ID 迚行版本回退
# git reset --hard 5ae4b06 #回退到指定 id 的版本
# git branch #查看当前所处的分支
# git checkout -- file #从服务器更新某个那文件覆盖本地的文件
©️2020 CSDN 皮肤主题: 游动-白 设计师:上身试试 返回首页