CentOS7 installation GitLab installation

GitLab installation

Replace Centos domestic data source

1. Back up the old configuration file

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2. Download Centos-Base.repo to /etc/yum.repos.d/

centos8:

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

centos7:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

centos6:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

And replace some fields (need to be done for non-Aliyun machines)

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

3. Generate cache

 yum makecache

4. Update

yum -y update

Install GitLab

1. Install and configure the necessary dependencies

Install the required dependencies on the CentOS system: ssh, firewall, postfix (for email notification), wget, the following commands will also open HTTP and SSH port access in the system firewall.

1. Install ssh

sudo yum install -y curl policycoreutils-pythonopenssh-server

insert image description here

Indicates that the installation is complete

2. Set the SSH service to start automatically at boot

sudo systemctl enable sshd

3. Start the SSH service

sudo systemctl start sshd

insert image description here

4. Install the firewall (firewalld is used here, if you already have other firewall software, you can directly skip to step 6)

yum install -y firewalld systemd

When it appears, the installation is complete.

insert image description here

5. Turn on the firewall

service firewalld start

insert image description here

6. Add http service to firewalld, pemmanent means permanent effect, if you don’t add –permanent, the system will be invalid after the next startup.

sudo firewall-cmd --permanent --add-service=http

7. After setting, you need to restart the firewall

sudo systemctl reload firewalld

8. Install Postfix

sudo yum install postfix

9. Set the Postfix service to start automatically at boot

sudo systemctl enable postfix

10. start postfix

sudo systemctl start postfix

During the installation of Postfix, a configuration screen may appear. Select "Internet Site" and press enter. Use your server's external DNS for "mail name" and press enter. If additional screens appear, continue to press enter to accept the defaults.

11.wget is used to download plug-ins from the Internet

Check whether wget has been installed in the system, use the view version command, and the version information appears, indicating that wget is installed, if not, it needs to be installed

wget view version information:

wget -V

The following figure appears, indicating that there is wget

insert image description here

no installation required

yum -y install wget

12. Install the vim editor, if you don’t want to install it, you can directly use the built-in vi editor

yum install -y vim

13. Install policycoreutils-python dependencies

yum install -y policycoreutils-python

2. Add GitLab mirror source and install gitlab server

1. Add the gitlab mirror (if you install 15.3.0 here and need to change the version, you can enter the mirror to select the required version)

GitLab community version mirror source: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.3.0-ce.0.el7.x86_64.rpm

If the issued certificate expires and cannot be downloaded, add the suffix --no-check-certificate

2. Install the gitlab command

rpm -i gitlab-ce-15.3.0-ce.0.el7.x86_64.rpm   # (后面根据自己下载版本而定)

The following figure appears, indicating that the installation is successful

insert image description here

3. Modify the gitlab configuration file to specify the server ip and custom port

vim /etc/gitlab/gitlab.rb

insert image description here

No domain name can set IP+port

A domain name can be changed to: gitlab.xxxx.xxxxt At the same time, port forwarding of Ngnix needs to be set

5. Reset and start Gitlab

gitlab-ctl reconfigure   # 重新加载Gitlab配置文件

gitlab-ctl restart   # 重新启动Gitlab

insert image description here

reboot complete

6. You also need to configure the open port of the firewall (according to the port you set, just open it)

firewall-cmd --zone=public --add-port=9982/tcp --permanent  # 打开9982端口
firewall-cmd reload # 配置完防火墙后需要重新加载一下

After the configuration is complete, access the configured address

insert image description here

Missing packages encountered during installation

When installing software in Centos, it prompts that the software has been installed, but both rpm -q and -e indicate that the package is not installed

View files and other information related to rpm packages

rpm -qa | grep 包名

Check if the package is installed

rpm -q 包名

remove package

rpm -e 包名

Run these three steps, delete the original package and re-download and install

3. Initialize the administrator password

Obtain/modify the password of the super administrator root

First enter the directory /opt/gitlab/bin, and then execute the following command to initialize the password

sudo gitlab-rails console production

After irb(main):001:0>, use u=User.where(id:1).first or u=User.where(name:“admin”) to find and switch accounts (User.all can view all users )

Set the password through u.password='xxxxx', where xxxxx is the root password that needs to be set.

Confirm the password again with u.password_confirmation='xxxxx'

Finally, save it through u.save! (with an exclamation mark after it!)

After saving, you can see that it returns true, indicating that it is successful, just execute exit to exit the current setting process.

If the above method does not work, you can try the method in the official document


gitlab-rails console -e production  # 输入指令进入控制台

user = User.where(id: 1).first 或  user = User.find_by(email: '[email protected]') # 选择root用户

user.password='xxxxx'  # 需要设定的密码

user.password_confirmation='xxxxx'  # 再次确认密码

user.save!  # 保存

You can also modify the user's password according to this method.

Replenish:

CentOS 7 firewall port command

The firewall in CentOS7 is commonly used as firewall. The following introduces the common methods of firewall:

>>> close firewall

systemctl stop firewalld.service  # 停止firewall
systemctl disable firewald.service  # 禁止firewall开机启动

>>>Open port

firewall-cmd --zone=public --add-port=80/tcp --permanent
含义:
--zone #作用域
--add-port=80/tcp #添加端口,格式为:端口/通讯协议
--permanent  # 永久生效,没有此参数重启后端口失效

>>>重新加载防火墙配置
firewall-cmd --reload

Common commands

firewall-cmd --state                           ##查看防火墙状态,是否是running
firewall-cmd --reload                          ##重新载入配置,比如添加规则之后,需要执行此命令
firewall-cmd --get-zones                       ##列出支持的zone
firewall-cmd --get-services                    ##列出支持的服务,在列表中的服务是放行的
firewall-cmd --query-service ftp               ##查看ftp服务是否支持,返回yes或者no
firewall-cmd --add-service=ftp                 ##临时开放ftp服务
firewall-cmd --add-service=ftp --permanent     ##永久开放ftp服务
firewall-cmd --remove-service=ftp --permanent  ##永久移除ftp服务
firewall-cmd --add-port=80/tcp --permanent     ##永久添加80端口 
iptables -L -n                                 ##查看规则,这个命令是和iptables的相同的
man firewall-cmd                               ##查看帮助

更多命令,使用  firewall-cmd --help 查看帮助文件

Guess you like

Origin blog.csdn.net/weixin_44030265/article/details/128865460