1.开启HTTP和SSH访问
yum install -y curl policycoreutils-pythonopenssh-server
2.开机启动SSH
systemctl enable sshd
3.启动SSH
systemctl start sshd
4.安装启用邮件服务
yum install postfix
5.开机启动邮件服务
systemctl enable postfix
6.启动邮件服务
systemctl start postfix
7.开机自启防火墙
systemctl enable firewalld
8.开启防火墙
systemctl start firewalld
9.开放端口号,gitlab默认端口号是80,用9220
firewall-cmd --permanent --zone=public --add-port=9220/tcp
10.重新加载防火墙
systemctl reload firewalld
11.安装python
yum install policycoreutils-python
12.下载Gitlab
本次选择版本为:gitlab-ce-15.9.2-ce.0.el7.x86_64.rpm,文件挺大,这个版本大概1.2G。所以选择用下载工具去国内镜像网站下
13.安装gitlab
进入下载目录,运行以下命令:
rpm -ivh gitlab-ce-15.9.2-ce.0.el7.x86_64.rpm
14.修改访问地址及端口
我看网上很多都写的配置这,配置那,还要配置nginx的,看得眼花缭乱。这里只需要配置gitlab.rb这个文件的external_url就行:
vim /etc/gitlab/gitlab.rb
修改内容如下:
external_url 'http://192.168.67.100:9220'
注意,9220端口要加入防火墙
注意,9220端口要加入防火墙
15.修改访问方式为https
1.修改/etc/gitlab/gitlab.rb
vim /etc/gitlab/gitlab.rb
修改内容:
external_url 'https://ip:port'
nginx['redirect_http_to_https'] =true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/server.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/server.key"
2.生成密钥证书
1.创建sh批处理,generate-cert.sh
#秘钥脚本,将以下内容保存为shell脚本,然后运行
#出现提示输入信息的地方输入信息,先输入域名然后4次证书密码,任意密码,四次保持一致。
#!/bin/sh
# create self-signed server certificate:
read -p "Enter your domain [139.199.125.93]: " DOMAIN
echo "Create server key..."
openssl genrsa -des3 -out $DOMAIN.key 1024
echo "Create server certificate signing request..."
SUBJECT="/C=US/ST=Mars/L=iTranswarp/O=iTranswarp/OU=iTranswarp/CN=$DOMAIN"
openssl req -new -subj $SUBJECT -key $DOMAIN.key -out $DOMAIN.csr
echo "Remove password..."
mv $DOMAIN.key $DOMAIN.origin.key
openssl rsa -in $DOMAIN.origin.key -out $DOMAIN.key
echo "Sign SSL certificate..."
openssl x509 -req -days 3650 -in $DOMAIN.csr -signkey $DOMAIN.key -out $DOMAIN.crt
echo "TODO:"
echo "Copy $DOMAIN.crt to /etc/nginx/ssl/$DOMAIN.crt"
echo "Copy $DOMAIN.key to /etc/nginx/ssl/$DOMAIN.key"
echo "Add configuration in nginx:"
echo "server {"
echo " ..."
echo " listen 443 ssl;"
echo " ssl_certificate /etc/nginx/ssl/$DOMAIN.crt;"
echo " ssl_certificate_key
2.执行批处理generate-cert.sh
./generate-cert.sh
3.输入Domain,自定义,就是生成文件名
192.168.67.100
4.连输4次密码
123456
5.根目录创建ssl文件夹(/etc/gitlab/ssl)并授权
1.mkdir /etc/gitlab/ssl
2.授权 chmod 700 /etc/gitlab/ssl -R
6.移动ssl证书到ssl目录
cp 192.168.67.100.crt /etc/gitlab/ssl/server.crt
cp 192.168.67.100.key /etc/gitlab/ssl/server.key
7.重启gitlab
gitlab-ctl reconfigure
16.修改root账号密码
方式一:
gitlab-rake "gitlab:password:reset[root]"
方式二,等待时间较长:
1.gitlab-rails console -e production
2.User.all,查看所有用户,#<User id:1 @root>
3.user=User.where(id:1).first
4.user.password='123456'
5.user.password_confirmation='123456'
6.user.save!
7.exit
17.常用命令
启动服务:gitlab-ctl start
查看状态:gitlab-ctl status
停掉服务:gitlab-ctl stop
重启服务:gitlab-ctl restart
让配置生效:gitlab-ctl reconfigure
18.本地文件提交到远程git服务器
1.情况一:创建普通项目
1.初始化
git init
2.提交到暂存区
git add .
3.提交到本地仓库
git commit -m 'first commit'
4.将本地仓库和远程仓库关联
git remote add origin http://ip/group/project-name.git
5.开始推送本地master分支到远程仓库
git push -u origin master
2.情况二:远程仓库分支继承主分支,但本地有需要提交代码
1.初始化
git init
2.创建新分支dev
git checkout -b dev
3.提交到暂存区
git add .
4.提交到本地仓库
git commit -a -m "first commit"
5.将本地仓库和远程仓库关联
git remote add origin http://ip/group/project-name.git
6.强制覆盖远程仓库dev分支
git push -f origin dev
7.远程库同步到本地库,这一步没试过,如果这一步可以,那么第6步将变为:git push -u orgin dev
git pull --rebase origin dev
文章评论