Build gitlab

Build gitlab

Build gitlab

1. Install and configure necessary packages


yum install -y curl openssh-server openssh-clients cronie

lokkit -s http -s ssh
 lokkit : command not found   lokkit 
yum install lokkit

 lokkit -s http -s ssh CentOS7 
ERROR: FirewallD is active, please use firewall-cmd.
systemct1 stop firewalld

2. Install gitlab package

curl -sS | sudo bash
yum install -y gitlab-ce

3. Installation is complete

4. Configure and start GitLab

gitlab-ctl reconfigure

Running handlers:
Running handlers complete
Chef Client finished, 479/1273 resources updated in 04 minutes 04 seconds
gitlab Reconfigured!

Visit http://ip address

Set a password and log in with root + password. Of course, you can also create a new user yourself.

5. SSH keys configuration

After that, add the public key on the server that will access this GitLab and you can play happily (Linux systems are generally in the/root/.ssh directory, Windows are generally in the C:\Users\username.ssh directory)

6. IP display and HTTP, SSH port configuration

After you complete the above operations, you will find that the SSH and HTTP addresses in your warehouse are as shown in the figure below, so we need to configure the IP display and port configuration for GitLab.

6.1 IP configuration

vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml

Modify the following items

    ## Web server settings (note: host is the FQDN, do not include http://)
    port: 6109
    https: false

Modify gitlab.rb

vim /etc/gitlab/gitlab.rb

external_url ''

After you complete the above configuration, you still cannot access your GitLab repository through http://ip location: prot.

6.2 HTTP port configuration

Modify GitLab ngnix listening port

vim /etc/gitlab/gitlab.rb

nginx['listen_port'] = 6109
vim /var/opt/gitlab/nginx/conf/gitlab-http.conf 

listen *:6109

After completing the above settings, you can access your GitLab library through IP + PORT, and the HTTP address of the warehouse is also displayed normally

6.3 SSH port configuration

To modify the SSH port, you must first modify the SSH port of the server, which will affect the connection of Xshell to the server.

  1. Modify the port number in sshd_config

    vim /etc/ssh/sshd_config

    Port 6119 //22
  2. Restart the sshd service

    systemct1 restart sshd

    systemct1 status sshd //

    localhost.localdomain sshd[50776]: error: Bind to port 6119 on  failed: Permission denied.
    localhost.localdomain sshd[50776]: error: Bind to port 6119 on  failed: Permission denied.

    SELinux  /etc/selinux/config 

    semanage port -a -t ssh_port_t -p tcp 6119
    systemct1 restart sshd
    systemct1 status sshd

    [root@localhost ~]# systemctl status sshd
    ?.sshd.service - OpenSSH server daemon
       Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
       Active: active (running) since Fri 2019-05-10 04:19:51 EDT; 5min ago
         Docs: man:sshd(8)
     Main PID: 36086 (sshd)
        Tasks: 1
       Memory: 1.0M
       CGroup: /system.slice/sshd.service
               ?..36086 /usr/sbin/sshd -D

    May 10 04:19:51 localhost.localdomain systemd[1]: Starting OpenSSH server daemon...
    May 10 04:19:51 localhost.localdomain sshd[36086]: Server listening on port 6119.
    May 10 04:19:51 localhost.localdomain sshd[36086]: Server listening on :: port 6119.
    May 10 04:19:51 localhost.localdomain systemd[1]: Started OpenSSH server daemon.

6.4 Restart GitLab

gitlab-ctl reconfigure
gitlab-ctl restart

After completing the above operations, everything is normal