Install Gitab under Ubuntu 1804

Deploy gitlab

1. Configure warehouse source

# vim /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

Update the source information

apt update 
# Install the basic software package and install by yourself as required
apt install iproute2 ntpdate tcpdump telnet traceroute nfs-kernel-server \ 
    nfs-common lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate \
    tcpdump telnet traceroute gcc openssh-server lrzsz tree openssl libssl-dev libpcre3 \
    libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute iotop unzip zip ipmitool

 

Installation and use of gitlab

Download address of installation package: https://packages.gitlab.com/gitlab/gitlab-ce
The domestic download address of rpm package: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/
Ubuntu domestic download address: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/

 

2. Using dpkg to install downloaded packages

dpkg -i gitlab-ce_11.11.5-ce.0_amd64.deb

 

 

 

3. Configuration after installation

[root@Gitlab1 gitlab]# grep "^[a-z]" /etc/gitlab/gitlab.rb
# Write local ip or domain name, domain name needs to be resolvable external_url
'http://192.168.99.160'
# The following configuration is optional, mail notification settings
gitlab_rails['smtp_address'] = "smtp.qq.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "583343636@qq.com" gitlab_rails['smtp_password'] = "xxxxxxxxxxxxxxxxxx" gitlab_rails['smtp_domain'] = "qq.com" gitlab_rails['smtp_authentication'] = :login gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = "583343636@qq.com" user["git_user_email"] = "583343636@qq.com"

 

4. Initialize the service and perform this operation after modifying the configuration file

gitlab-ctl reconfigure

 

5. Directory related to gitlab

/etc/gitlab #Profile directory
/run/gitlab #Run pid directory
/opt/gitlab #Installation directory
/var/opt/gitlab #Data directory
/var/log/gitlab #Log directory

Frequently used commands

Gitlab rails: used to start the console for special operations, such as changing the administrator password, opening the database console (gitlab rails dbconsole), etc
 Gitlab PSQL: database command line
 Gitlab rake: data backup and recovery and other data operations
 Gitlab CTL: client command line operation line
 Gitlab CTL stop: stop gitlab
 Gitlab CTL start: start gitlab
 Gitlab CTL restart: restart gitlab
 Gitlab CTL status: view component running status
 Gitlab CTL tail nginx: view the log of a component

Database command line

Verify the completion of gitlab installation

gitlab-ctl status

 

Verify that the port status is 80. The port is started when gitlib is initialized. Therefore, if the previous program is occupied, the initialization will fail or cannot be accessed!  

6. Access the IP address through the browser, log in to the gitlab web interface and set the password:

Enter the user name and password. The user is root and the password is set in the previous step

Log in to the home page

7. Close account registration (it is allowed to register account by default, which is not safe). This function is used internally, so it can be registered

Exit to see if there are registration options

Simple use of Gitlab

1. Create a user

2. The reset link will be generated and sent to the user. The user will be forced to set the password the first time they log in.

Or set the password directly

Log in with a new account

Password will be forced to change after login

3. If no password is specified when creating a user, an email will be sent to the mailbox. At this time, if the email service is not set up before, no email will be received

 

Click Reset password to set the password

 

4. Log in with root account and create a new group

 

There can be multiple project branches in a group. You can add development to the group to set permissions. Different groups are different development projects or service modules of the company. Different groups can add different development to realize the management of development setting permissions

5. Enter the group and create a project

Fill in the information - create a web project

Add user to group

6. Add a test page and a new file to the project

Edit a content test

 

7. Copy the link address of the clone. Here, select http to test the clone on the client. (ssh is not configured yet.)

8. Clone and download the project to the client

# If you don't have the git command, install it
    apt install -y git
# Clone
git clone http://192.168.99.160/dev/web1.git

You can see the content of the index.html page in the cloned web project

9. Configure account password

git config --global user.name "root"
git config --global user.email xxxx@qq.com

 

10. Modify the contents of the file, and then push it to the gitlab branch

Go to gitlab to view the new code of new push upload

 

Check the contents of the file to prove that the code is updated successfully

The above is the basic use of Gitlab. Jenkins will be built later, and then it will cooperate with Gitlab to realize the automatic deployment, update or rollback of code

Tags: Linux GitLab Ubuntu git Database

Posted on Sat, 11 Jan 2020 22:53:11 -0800 by tunage