1.安装centos7.9虚拟机系统,设置网络模式为仅主机,配置固定IP地址,确保系统只能在局域网访问,无法访问外网。
2.使用ssh连接服务器,上传gitlab-ce安装包。这里选择使用gitlab-ce15.11.13版本,无安全漏洞。前置操作关闭操作系统防火墙,关闭selinux等操作忽略。
gitlab-ce多版本下载链接: https://pan.baidu.com/s/1FymwmEMKafURfS_UedZlkQ?pwd=rn4z 提取码: rn4z
3.使用yum命令安装。
[root@localhost ~]# yum install gitlab-ce-15.11.13-ce.0.el7.x86_64.rpm
安装过程如下。因为无法连接,yum员检测需要较慢,耐心等待。安装过程也需要时间。安装完成后显示gitlab图标,说明安装完成。
[root@localhost ~]# yum install gitlab-ce-15.11.13-ce.0.el7.x86_64.rpm
Loaded plugins: fastestmirror, langpacks
Examining gitlab-ce-15.11.13-ce.0.el7.x86_64.rpm: gitlab-ce-15.11.13-ce.0.el7.x86_64
Marking gitlab-ce-15.11.13-ce.0.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package gitlab-ce.x86_64 0:15.11.13-ce.0.el7 will be installed
--> Finished Dependency Resolution
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.aliyun.com; Unknown error"
Trying other mirror.
http://mirrors.aliyun.com/centos/7/extras/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.aliyun.com; Unknown error"
Trying other mirror.
^C^C^C^C
Current download cancelled, interrupt (ctrl-c) again within two seconds
to exit.
file:///mnt/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /mnt/repodata/repomd.xml"
Trying other mirror.
^C^C^C^C
Dependencies Resolved
===============================================================================================================
Package Arch Version Repository Size
===============================================================================================================
Installing:
gitlab-ce x86_64 15.11.13-ce.0.el7 /gitlab-ce-15.11.13-ce.0.el7.x86_64 2.6 G
Transaction Summary
===============================================================================================================
Install 1 Package
Total size: 2.6 G
Installed size: 2.6 G
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : gitlab-ce-15.11.13-ce.0.el7.x86_64 [############################################################################################### ] 1/1 Installing : gitlab-ce-15.11.13-ce.0.el7.x86_64 1/1 ###################################################################
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=15-11
Verifying : gitlab-ce-15.11.13-ce.0.el7.x86_64 1/1
Installed:
gitlab-ce.x86_64 0:15.11.13-ce.0.el7
Complete!
[root@localhost ~]#
4.安装完成后,按照提示信息配置external_url,可以配置为主机名称,或者IP地址。可以参考官方文档。Configuration options for Linux package installations | GitLab
[root@localhost ~]# vim /etc/gitlab/gitlab.rb
#external_url 'http://gitlab.example.com'
external_url 'http://192.168.159.159'
最好同步修改一下时区,否则系统显示的提交时间不一致。
# gitlab_rails['time_zone'] = 'UTC'修改为gitlab_rails[‘time_zone’] = 'Asia/Shanghai'
5.配置完成后,使gitlab配置生效。
[root@localhost ~]# gitlab-ctl reconfigure
过程较慢,耐心等待。一直等,不要进行其他操作,等完成后输出信息如下。
Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.
NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
[2024-04-28T00:20:56-07:00] WARN: This release of Cinc Client became end of life (EOL) on May 1st 2023. Please update to a supported release to receive new features, bug fixes, and security updates.
gitlab Reconfigured!
[root@localhost ~]#
6.按照提示信息找到密码文件,用户名是root,密码要记好,24小时候就自动删除了。
cat /etc/gitlab/initial_root_password
7.查看监听端口信息。可以看到监听的是80端口。
8、在浏览器打开网址访问,若显示502超时,说明服务启动较慢,等几分钟在访问就可以了。
9.如果需要修改gitlab的访问端口,在配置文件中修改即可,修改后仍然需要重新配置和启动服务。
external_url 'http://192.168.159.159:8080'
10.登陆之后可以设置为中文,设置-参数中修改即可。
11.配置https访问,修改信息如下:
external_url 'https://192.168.159.159'
gitlab_rails['time_zone'] = 'Asia/Shanghai'
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/server.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/server.key"
letsencrypt['enable'] = false
12.SSL证书的生成方法
1.生成私钥
openssl genrsa -out server.key 2048
2.生成请求文件
openssl req -new -key server.key -out server.csr
3.生成自签名证书
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.pem -outform PEM
4.转换为fpx格式
openssl crl2pkcs7 -nocrl -certfile server.crt -outform DER -out server.p7b