Installation, configuration and uninstallation of GitLab in Ubuntu19.1

Article Directory

I. Overview##

gitlab is an open source hosted Git repository.

git related concepts:
git is a version control system, a command, a tool
gitlib is a development library used to implement git functions
Github is an online code hosting warehouse based on git, including a website interface, open to the Internet
Gitlab is an online code warehouse hosting software based on git, generally used to build git private servers on the corporate intranet
Note: gitlab-ce community edition; gitlab-ee is enterprise edition, chargeable

Second, build the environment##

1、 Virtual machine configuration###

Since gitlab eats more resources, you must ensure that the configuration of the virtual machine should be at least this:

And don’t open the browser and other applications after installation, otherwise it will be like this:

As you can see, the CPU and RAM all went viral.

My mentality collapsed.

2、 Turn on the firewall###

Because LInux's original firewall tool iptables is too cumbersome, ubuntu provides a firewall tool ufw based on iptable by default.

sudo  ufw enable|disable

View the status of the firewall:

sudo ufw status

Open or close a port, for example:

//Allow all external IPs to access the machine's 25/tcp (smtp)port
sudo ufw allow smtp
//Prohibit external access to smtp services
sudo ufw deny smtp
//Delete a rule established above
sudo ufw delete allow smtp

For our installation of gitlab this time, we only need to guarantee these three, please execute in order:

sudo ufw allow http
sudo ufw allow https
sudo ufw allow OpenSSH

3、 Install dependencies###

Before we install GitLab ourselves, it is very important to install some software that we continue to use during the installation process. All necessary software can be easily installed from Ubuntu's default package repository.

Enter separately:

//Refresh the local package index
sudo apt update
//Install dependencies
sudo apt install ca-certificates curl openssh-server postfix

If you encounter the following problem when installing:

Please refer to this article of mine to change the source: Change source, come back and continue the following operation after finishing:

May let you set up an email:

//I set this,Set up casually,You can change it later, you can choose Enter to skip
 [email protected]

Open HTTP and SSH ports:

 iptables -I INPUT -m tcp -p tcp --dport 22-j ACCEPT
 iptables -I INPUT -m tcp -p tcp --dport 80-j ACCEPT
 //If you are prompted Permission Denied, it means that the permissions are insufficient,The solution is to add sudo in front//Or switch to admin: sudo su
apt-get--purge remove postfix

Three, install GitLab

The official download address is too slow, here we change the source:

1、 First trust GitLab's GPG public key:

curl https://packages.gitlab.com/gpg.key 2>/dev/null| sudo apt-key add -&>/dev/null

2、 Then use the root account to open vi:

sudo su
vi /etc/apt/sources.list.d/gitlab-ce.list

3、 Paste the content below

deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial main
//Paste into the text, press Esc, and type:, And finally enter wq to save and exit.

4、 Install gitlab-ce:

sudo apt-get update
sudo apt-get install gitlab-ce

5、 Open sshd and postfix services

service sshd start
service postfix start

6、 Start gitlab after the installation is complete

The initial startup will be relatively long, if the computer configuration is low, it will become a dog.

Supplement: The time is super invincible, depending on your computer configuration.

sudo gitlab-ctl reconfigure

7、 Open in the browser: http://127.0.0.1.

But it is not recommended to do this in a virtual machine. It is recommended to obtain the ip address of the virtual machine first, and then access it on your own computer. For example, my ip address is 192.168.2.105, and you can access it like this:

http://192.168.2.105

How to get the IP address:

ifconfig
//If there is no net-tools,Follow his instructions to install.//Seems to be this command
apt install net-tools

When using it for the first time, GitLab will prompt to set a password. The default configuration is the password of the root user. After setting it, it can be used normally.

Fourth, configure GitLab

1、 Configure domain address###

1、 Type vim /etc/gitlab/gitlab.rb to open the file, and change external_url ='http://git.example.com' to your own IP or HostName, for example:

external_url ='http://192.168.2.105'


The following are advanced operations, please ignore it

2、 Configure postfix

To configure GitLab's outgoing mailbox, we can use the following command to test the publishing and sending of emails:

Execute the following command to test sending mail:

sudo apt-get install mailutils
echo "Test mail from postfix" [email protected]

It takes a long time to receive the email. It is recommended to do other things first.

Then he will inexplicably have a hint after a while:

I was scared at the time, but very curious, so I went in and took a look:

vim /var/mail/root

After opening:

Write down the system sending email address:

I am this:

" MAILER-DAEMON@wsuo"@ubuntu-gitlab.com

Then open the vim /etc/gitlab/gitlab.rb file and modify gitlab_rails['gitlab_email_from'] ='[email protected]' to the system sending email address:

gitlab_rails['gitlab_email_from']='"MAILER-DAEMON@wsuo"@ubuntu-gitlab.com'

After the above configuration is complete, you can start GitLab:

sudo gitlab-ctl reconfigure

3、 Configure SMTP service###

If you think this is too cumbersome, you don't need to set it up, it will not have any effect on your operation, but you can't receive mail messages, you can also use Tencent's mail system:

Modify the GitLab mail service configuration (gitlab.rb file), use the SMTP server of Tencent Enterprise Mailbox, and fill in the account and password

gitlab_rails['smtp_address']="smtp.exmail.qq.com"
gitlab_rails['smtp_port']=25
gitlab_rails['smtp_user_name']="xxx"
gitlab_rails['smtp_password']="xxx"
gitlab_rails['smtp_domain']="smtp.qq.com"
gitlab_rails['smtp_authentication']='plain'
gitlab_rails['smtp_enable_starttls_auto']=true

Make the configuration effective:

gitlab-ctl reconfigure
gitlab-rake cache:clear RAILS_ENV=production      #clear cache

Attach common commands:

//View version information
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION

//12.8.1

Five, uninstall GitLab

After installing it, I regret it, and the card can't be moved, because after the installation is completed, it will start automatically after the boot. What happened to a good virtual machine?

So I felt that I would return a youthful and beautiful image of my Ubuntu and uninstall the nasty gitlab:

Before uninstalling, let's take a look at where it is installed. Because we installed it through the apt command, it will be installed in the /opt directory. Let's see if it looks like this:

We found that this kid was indeed here, then he was dead.

The following execution of our extinction plan:

1、 Stop running

sudo gitlab-ctl stop

2、 Execute uninstall command

Execute the following command and restart the system

Pay attention to this piece, see if it is the gitlab-ce version or the gitlab-ee version, don’t make a mistake

//Because we installed it using Synaptic, we directly execute the command
sudo apt-get remove gitlab-ce is equivalent to this command:  sudo apt-get--purge remove gitlab-ce
//Just execute this command,Uninstall this software on your computer,If you want to delete more thoroughly,You can continue to execute the following command
# Delete the staged software installation package
sudo apt-get clean gitlab-ce

You will be asked to enter y once during the deletion process:

After the execution, I took a look and found that there was only 2M in the original file:

3、 View gitlab process

ps -ef|grep gitlab

Kill the first process:

kill -98922

Then it's gone after viewing.

4、 Delete gitlab file###

//Delete all files and directories containing gitlab
find /-name gitlab|xargs rm -rf 

When deleting gitlab-ctl uninstall, the configuration file automatically backed up under root:

cd /root
rm -rf /root/gitlab then automatically completes by tab

For example, mine is:

root@ubuntu:~# rm -rf gitlab-cleanse-2020-02-29T08\:43/

Six, problems encountered##

1、 gitlab installation error###

An error is reported when executing sudo apt-get install gitlab-ce:

The text information is as follows:

There was an error running gitlab-ctl reconfigure:

gitlab_sysctl[kernel.shmmax](postgresql::enable line 67) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[load sysctl conf kernel.shmmax](/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/resources/gitlab_sysctl.rb line 46) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with[0], but received '255'---- Begin output of sysctl -e --system ----
STDOUT:* Applying /etc/sysctl.d/10-console-messages.conf ...
kernel.printk =4417* Applying /etc/sysctl.d/10-ipv6-privacy.conf ...
net.ipv6.conf.all.use_tempaddr =2
net.ipv6.conf.default.use_tempaddr =2* Applying /etc/sysctl.d/10-kernel-hardening.conf ...
kernel.kptr_restrict =1* Applying /etc/sysctl.d/10-link-restrictions.conf ...
fs.protected_hardlinks =1
fs.protected_symlinks =1* Applying /etc/sysctl.d/10-magic-sysrq.conf ...
kernel.sysrq =176* Applying /etc/sysctl.d/10-network-security.conf ...
net.ipv4.conf.default.rp_filter =2
net.ipv4.conf.all.rp_filter =2* Applying /etc/sysctl.d/10-ptrace.conf ...
kernel.yama.ptrace_scope =1* Applying /etc/sysctl.d/10-zeropage.conf ...
vm.mmap_min_addr =65536* Applying /usr/lib/sysctl.d/30-tracker.conf ...
fs.inotify.max_user_watches =65536* Applying /usr/lib/sysctl.d/50-default.conf ...
net.ipv4.conf.all.promote_secondaries =1
net.core.default_qdisc = fq_codel
* Applying /etc/sysctl.d/90-omnibus-gitlab-kernel.sem.conf ...* Applying /etc/sysctl.d/90-omnibus-gitlab-kernel.shmall.conf ...* Applying /etc/sysctl.d/90-omnibus-gitlab-kernel.shmmax.conf ...
kernel.shmmax =17179869184* Applying /etc/sysctl.d/90-omnibus-gitlab-net.core.somaxconn.conf ...* Applying /etc/sysctl.d/99-sysctl.conf ...* Applying /etc/sysctl.d/protect-links.conf ...
fs.protected_hardlinks =1
fs.protected_symlinks =1* Applying /etc/sysctl.conf ...
STDERR: sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-kernel.sem.conf":No such file or directory
sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-kernel.shmall.conf":No such file or directory
sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-net.core.somaxconn.conf":No such file or directory
- - - - End output of sysctl -e --system ----
Ran sysctl -e --system returned 255

It was all red, and I was frightened.

Go to the GitLab forum to find a solution:

touch /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
touch /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf

2、 Start 502

I took it. It was good, but suddenly it got 502 inexplicably. I guess it’s the timeout problem. Just go to the configuration file to find it and set it for a longer time:

1、 open a file:

vim /etc/gitlab/gitlab.rb

2、 Change the time

Find these two places:

gitlab_rails[‘webhook_timeout’] = 90
gitlab_rails[‘git_timeout’]=90

3、 Update configuration file

sudo gitlab-ctl reconfigure

Then I am just finished modifying the above files, if you still can’t?

Try to modify the port:

unicorn['port']=8888

gitlab_workhorse['auth_backend']="http://localhost:8888" 

Note: unicorn['port']With gitlab_workhorse['auth_backend']Must be the same

If you still can't, please go back and perform step 5-uninstall-reinstall.

Recommended Posts

Installation, configuration and uninstallation of GitLab in Ubuntu19.1
Installation and uninstallation of CUDA under Ubuntu 16.04
Installation and deployment of Nginx in Ubuntu
Installation and configuration of JDK in CentOS 7 system
Installation and configuration of CentOS 7 in VMware Workstation
Installation and use of SSH in Ubuntu environment
Ubuntu16.04 installation and simple configuration
Ubuntu PostgreSQL installation and configuration
Installation and use of GDAL in Python under Ubuntu
Installation and simple practice of MySQL in ubuntu environment (1)
Centos7 installation and configuration of Jenkins
Happy installation of Jenkins in ubuntu
CentOS7 installation and maintenance of Gitlab
Installation instructions for gitlab in Ubuntu
Ubuntu 19.1 installation and configuration Chinese environment
Configuration and beautification after Ubuntu installation (1)
Nginx installation and configuration load (ubuntu12.04)
Ubuntu configuration source and installation software
ubuntu Docker installation and deployment of Rancher
Installation and configuration of redis under centos7
Centos7 installation and deployment of gitlab server
Installation and use of Win10 subsystem Ubuntu
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
Detailed explanation of quick installation and configuration of Subversion (SVN) under Ubuntu
Detailed explanation of the installation and use of SSH in the Ubuntu environment
Debian and Ubuntu installation source configuration file description
OpenMPI-Ubuntu installation and configuration
Installation of pulseaudio and API usage under Ubuntu 12.04
Ubuntu introduction and installation
Installation and configuration of rsync server under CentOS 6.5
Kaldi installation and configuration graphic tutorials under Ubuntu
Basic configuration and common software installation after ubuntu 18.04 installation
Detailed explanation of static DNS configuration method in Ubuntu
Ubuntu16.04 mirror complete installation and configuration tutorial under VMware
Common exceptions and solutions for Ubuntu system installation and configuration
Installation and usage instructions of rz/sz command under ubuntu
Centos mysql installation and configuration
Centos7 installation and configuration prometheus
Use of Anaconda in Ubuntu
CentOS 7 installation and configuration PPTP
CentOS installation and configuration cmake
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
ubuntu install and configure GitLab
GitLab installation and basic use
Ubuntu16.04 install SVN and configuration
Enterprise self-built GitLab code warehouse installation and basic configuration use
Detailed explanation of Spark installation and configuration tutorial under centOS7
Ubuntu environment variables and ADB configuration
Centos6.5 installation and deployment of KVM
Centos7 hadoop cluster installation and configuration
Install and configure Docker in Ubuntu
Ubuntu16.04 configuration OpenCV3.4.2 and basic use
Redis installation under ubuntu and windows
Java-JDK installation and configuration under CentOS
CentOS 7 Tomcat service installation and configuration
CentOS NTP server installation and configuration
Installation of Docker CE under Ubuntu
Ubuntu18.04 installation Anaconda3 and VSCode guide
Coexistence of CUDA8.0 and CUDA9.0 under Ubuntu 16.04
Centos7 mysql database installation and configuration