一、注册
gitlab官网注册入口:
https://about.gitlab.com/downloads/#centos7
https://gitlab.com/users/sign_in
一般注册免费版即可
二、安装和配置依赖项 (必需)
官方centos7配置链接:https://about.gitlab.com/installation/#centos-7
1.安装软件
sudo yum install curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
2.防火墙设置
sudo firewall-cmd –permanent –add-service=http
sudo systemctl reload firewalld
3.安装postfix发送通知邮件。(可跳过)
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
4.添加gitlab库及安装包。
官方方法:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
我的操作:
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
yum repolist 查看库中是否有包
5.安装gitlab包
官方方法:(安装gitlab包。改变http://gitlab.example.com
的URL为你想访问的你的gitlab实例。安装将自动配置和URL开始gitlab。HTTPS需要在安装后附加配置)
sudo EXTERNAL_URL=”http://gitlab.example.com” yum install -y gitlab-ee
我的操作:
sudo yum install gitlab-ce 或 yum -y install gitlab-ce-8.14.4-ce.0.el7.x86_64.rpm
sudo gitlab-ctl reconfigure 自动配置文件权限,安装数据库(安装的时间很长)
三、访问
浏览器访问gitlab服务器网址 (GITLAB占用80端口,访问时直接访问IP就可以
,第一次会让你确认root账户登录的密码)
http://192.168.122.163
此图为确认密码后跳转的页面
接着,输入root ,及第一次设的密码即可
四、创建项目
此项目的存储库是空的。
如果已经有文件,可以使用下面的命令行指令来推送它们。
否则,你可以开始添加一个自述,许可证,或gitignore这个项目。
当主分支被自动保护时,您将需要拥有或拥有初始推送的主权限级别。
它将根据预定义的CI / CD配置自动构建、测试和部署应用程序。
Command line instructions
1.Git的全局设置
git config –global user.name “Administrator”
git config –global user.email “admin@example.com”
2.创建一个新的存储库
git clone git@gitlab.example.com:root/ali.git
cd ali
touch README.md
git add README.md
git commit -m “add README”
git push -u origin master
3.现有文件夹方式
cd existing_folder
git init
git remote add origin git@gitlab.example.com:root/ali.git
git add .
git commit -m “Initial commit”
git push -u origin master
4.现有Git仓库方式
cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.example.com:root/ali.git
git push -u origin –all
git push -u origin –tags
五、推送SSH秘钥
1.粘贴这个地址,用于下载项目(文档容器)
http://192.168.122.163/root/ali root后为项目名
2.客户端生成秘钥
ssh-keygen
cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0Gprw28nQpAzIstXUSBMotDjSqfZ1sA2nKwaYxIpidvAnAiO1nBwNNMW+iDO81ByV/EYAsMs2ZS+NCp6sqttdSlhGgSuc2wbCACx1V+wmqi+hU4AFduEkG1CEbIVUZsaF3WLHVl4Vegb8T6Z5qJSKXa7GW4Vt1pDKM2RkwLrcjetDubLEL61B+FCHn2HK4C8JUOeChzvdgH0hs5GE9IsO31jctmQE/bjM0gAjNd37qoRDe96+ghiWrObPkZc9BpiOseMc74mlJwS7IWvUvA9PlRJHxWYw9tEKS7ElN52BYdOZTKzUxMCZgkcpo12cJzd5sMLY/KV1sTaGkEOEfaoX root@www.master.com
3上传秘钥
4查看秘钥
5链接地址 用于命令行,或客户端程序进行下载使用。
http://192.168.122.163/root/ali
6.gitlab使用 (可返回第四节观察命令)
http://192.168.122.163/root/ali (ali应改为你自己的项目名)下方会有命令提示
六、gitlab 开启,关闭
开启
sudo gitlab-ctl start
关闭
sudo gitlab-ctl stop
重启
sudo gitlab-ctl restart
结尾:文件共享
1.cat script.rpm.sh 此文件在此有转码问题,将其全部拉下复制粘贴到txt文档,即可用
#!/bin/bash
unknown_os ()
{
echo “Unfortunately, your operating system distribution and version are not supported by this script.”
echo
echo “You can override the OS detection by setting os= and dist= prior to running this script.”
echo “You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version”
echo
echo “For example, to force CentOS 6: os=el dist=6 ./script.sh”
echo
echo “Please email support@packagecloud.io and let us know if you run into any issues.”
exit 1
}
curl_check ()
{
echo “Checking for curl…”
if command -v curl > /dev/null; then
echo “Detected curl…”
else
echo “Installing curl…”
yum install -d0 -e0 -y curl
fi
}
detect_os ()
{
if [[ ( -z “{os}" ) && ( -z "
if [ -e /etc/os-release ]; then
. /etc/os-release
os= IDif[“
{os}” = “poky” ]; then
dist=echo ${VERSION_ID}
elif [ “${os}” = “sles” ]; then
dist=echo ${VERSION_ID}
elif [ “${os}” = “opensuse” ]; then
dist=echo ${VERSION_ID}
else
dist=echo ${VERSION_ID} | awk -F '.' '{ print $1 }'
fi
elif [ `which lsb_release 2>/dev/null` ]; then
# get major version (e.g. '5' or '6')
dist=`lsb_release -r | cut -f2 | awk -F '.' '{ print $1 }'`
# get os (e.g. 'centos', 'redhatenterpriseserver', etc)
os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`
elif [ -e /etc/oracle-release ]; then
dist=`cut -f5 --delimiter=' ' /etc/oracle-release | awk -F '.' '{ print $1 }'`
os='ol'
elif [ -e /etc/fedora-release ]; then
dist=`cut -f3 --delimiter=' ' /etc/fedora-release`
os='fedora'
elif [ -e /etc/redhat-release ]; then
os_hint=`cat /etc/redhat-release | awk '{ print tolower($1) }'`
if [ "${os_hint}" = "centos" ]; then
dist=`cat /etc/redhat-release | awk '{ print $3 }' | awk -F '.' '{ print $1 }'`
os='centos'
elif [ "${os_hint}" = "scientific" ]; then
dist=`cat /etc/redhat-release | awk '{ print $4 }' | awk -F '.' '{ print $1 }'`
os='scientific'
else
dist=`cat /etc/redhat-release | awk '{ print tolower($7) }' | cut -f1 --delimiter='.'`
os='redhatenterpriseserver'
fi
else
aws=`grep -q Amazon /etc/issue`
if [ "$?" = "0" ]; then
dist='6'
os='aws'
else
unknown_os
fi
fi
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
fi
if [[ ( -z “os")||(−z"
{dist}” ) ]]; then
unknown_os
fi
# remove whitespace from OS and dist name
os=”os///”dist=”
{dist// /}”
echo “Detected operating system as os/
{dist}.”
}
finalize_yum_repo ()
{
echo “Installing pygpgme to verify GPG signatures…”
yum install -y pygpgme –disablerepo=’gitlab_gitlab-ce’
pypgpme_check=rpm -qa | grep -qw pygpgme
if [ “$?” != “0” ]; then
echo
echo “WARNING: ”
echo “The pygpgme package could not be installed. This means GPG verification is not possible for any RPM installed on your system. ”
echo “To fix this, add a repository with pygpgme. Usualy, the EPEL repository for your system will have this. ”
echo “More information: https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F”
echo
# set the repo_gpgcheck option to 0
sed -i'' 's/repo_gpgcheck=1/repo_gpgcheck=0/' /etc/yum.repos.d/gitlab_gitlab-ce.repo
- 1
- 2
- 3
fi
echo “Installing yum-utils…”
yum install -y yum-utils –disablerepo=’gitlab_gitlab-ce’
yum_utils_check=rpm -qa | grep -qw yum-utils
if [ “$?” != “0” ]; then
echo
echo “WARNING: ”
echo “The yum-utils package could not be installed. This means you may not be able to install source RPMs or use other yum features.”
echo
fi
echo “Generating yum cache for gitlab_gitlab-ce…”
yum -q makecache -y –disablerepo=’*’ –enablerepo=’gitlab_gitlab-ce’
}
finalize_zypper_repo ()
{
zypper –gpg-auto-import-keys refresh gitlab_gitlab-ce
}
main ()
{
detect_os
curl_check
yum_repo_config_url=”https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.repo?os={os}&dist=
{dist}&source=script”
if [ “os"="sles"]||["
{os}” = “opensuse” ]; then
yum_repo_path=/etc/zypp/repos.d/gitlab_gitlab-ce.repo
else
yum_repo_path=/etc/yum.repos.d/gitlab_gitlab-ce.repo
fi
echo “Downloading repository file: ${yum_repo_config_url}”
curl -sSf “yumrepoconfigurl">
yum_repo_path
curl_exit_code=$?
if [ “curlexitcode”=“22”];thenechoechoecho−n“Unabletodownloadrepoconfigfrom:”echo“
{yum_repo_config_url}”echo
echo “This usually happens if your operating system is not supported by ”
echo “packagecloud.io, or this script’s OS detection failed.”
echo
echo “You can override the OS detection by setting os= and dist= prior to running this script.”
echo “You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version”
echo
echo “For example, to force CentOS 6: os=el dist=6 ./script.sh”
echo
echo “If you are running a supported OS, please email support@packagecloud.io and report this.”
[ -e yum_repo_path ] && rmyum_repo_path
exit 1
elif [ “ curlexitcode"="35"−o"curl_exit_code” = “60” ]; then
echo
echo “curl is unable to connect to packagecloud.io over TLS when running: ”
echo ” curl yumrepoconfigurl”echoecho“Thisisusuallyduetooneoftwothings:”echoecho”1.)MissingCArootcertificates(makesuretheca−certificatespackageisinstalled)”echo”2.)Anoldversionoflibssl.Tryupgradinglibsslonyoursystemtoamorerecentversion”echoecho“Contactsupport@packagecloud.iowithinformationaboutyoursystemforhelp.”[−eyum_repo_path ] && rm yumrepopathexit1elif[“curl_exit_code” -gt “0” ]; then
echo
echo “Unable to run: ”
echo ” curl yumrepoconfigurl”echoecho“Doublecheckyourcurlinstallationandtryagain.”[−e
yum_repo_path ] && rm $yum_repo_path
exit 1
else
echo “done.”
fi
if [ “os"="sles"]||["
{os}” = “opensuse” ]; then
finalize_zypper_repo
else
finalize_yum_repo
fi
echo
echo “The repository is setup! You can now install packages.”
}
main
- 1
2.cat gitlab_gitlab-ce.repo
[gitlab_gitlab-ce]
name=gitlab_gitlab-ce
baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/7/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
[gitlab_gitlab-ce-source]
name=gitlab_gitlab-ce-source
baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/7/SRPMS
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300