Deploy GitLab

更新时间:
复制 MD 格式

Deploying GitLab on an ECS instance gives you a self-managed code hosting and CI/CD platform with private access and on-premises data storage. You can deploy GitLab on a Linux ECS instance by using an installation package, a Docker image, or an ECS extension.

Prerequisites

The ECS instance must meet the following requirements:

  • Instance type: A minimum of 4 vCPUs and 8 GiB of memory is recommended, depending on your project and team size. For more information, see Installation system requirements and Running GitLab in a memory-constrained environment.

    Important

    An instance with less than 4 vCPUs and 8 GiB of memory may hang during installation or fail. Upgrade the instance type before you start the installation. For more information, see Configuration change overview.

  • Operating system: Linux. For a list of supported distributions, see Supported OSes.

  • A public IP address is automatically assigned to the ECS instance. Alternatively, an elastic IP address (EIP) is associated with the ECS instance. For instructions on how to enable public bandwidth, see Enable public bandwidth.

  • Security group: Configure an inbound rule to allow traffic on ports 80, 443, and 22. For instructions, see Add a security group rule.

Install GitLab

GitLab is available in Enterprise Edition (EE) and Community Edition (CE). JiHu GitLab is an enterprise-grade version distributed in the Chinese mainland, Hong Kong (China), and Macao (China), with servers located within China for faster access. For a detailed version comparison, see JiHu GitLab installation and version comparison.

Installation package

For users in the Chinese mainland, JiHu GitLab is recommended for faster download and access speeds. Choose GitLab Community Edition when you need to collaborate with teams outside of China or require full consistency with the GitLab Community Edition codebase and documentation.

JiHu GitLab

For a list of operating systems supported by JiHu GitLab, see supported_os.

Alibaba Cloud Linux 3

  1. Connect to a Linux instance by using Workbench.

  2. Download the latest RPM installation package to a local temporary directory. The command dynamically reads the current primary.xml.gz filename from repomd.xml (the hash in this filename changes with each repository reindex), and then parses the relative path of the latest RPM and downloads it.

    cd /tmp && \
    ARCH=$(uname -m) && \
    PRIMARY=$(curl -s https://packages.gitlab.cn/repository/el/8/repodata/repomd.xml \
        | grep -oE "[a-f0-9]{64}-primary\.xml\.gz" | head -1) && \
    URL=$(curl -s "https://packages.gitlab.cn/repository/el/8/repodata/${PRIMARY}" \
        | gunzip \
        | grep -oE "href=\"[^\"]*gitlab-jh[^\"]*${ARCH}\.rpm\"" \
        | sed 's/href="//;s/"$//' \
        | sort -V \
        | tail -1) && \
    wget -c "https://packages.gitlab.cn/repository/el/8/${URL}"
  3. Install the RPM package downloaded in the previous step. The command uses a glob wildcard to match the downloaded version, preventing a version mismatch. The output Complete! indicates that the RPM installation is successful.

    RPM=$(ls /tmp/gitlab-jh-*.x86_64.rpm | sort -V | tail -1) && \
    sudo yum localinstall -y --disablerepo=gitlab-jh "$RPM" && rm -f "$RPM"
    The --disablerepo=gitlab-jh parameter prevents `yum` from refreshing the metadata of the `gitlab-jh` remote repository when you install a local RPM package. This avoids an Out of Memory (OOM) error, which can be triggered by an exception during repository metadata parsing and cause the installation to fail.
  4. Configure the external access URL and start GitLab.

    Replace ECS_PUBLIC_IP with the public IP address of the ECS instance.

    sudo EXTERNAL_URL="http://ECS_PUBLIC_IP" gitlab-ctl reconfigure
    The initial run takes about 5 to 10 minutes to complete.
  5. Verify the service status.

    sudo gitlab-ctl status

    The output shows that processes such as puma, sidekiq, nginx, postgresql, redis, and prometheus are all in the run state, which indicates that GitLab has started successfully.

Alibaba Cloud Linux 4

  1. Connect to a Linux instance by using Workbench.

  2. Create the repository file.

    sudo tee /etc/yum.repos.d/gitlab-jh.repo > /dev/null << 'EOF'
    [gitlab-jh]
    name=JiHu GitLab
    baseurl=https://packages.gitlab.cn/repository/el/9/
    gpgcheck=1
    gpgkey=https://packages.gitlab.cn/repository/raw/gpg/public.gpg.key
    priority=1
    enabled=1
    EOF
  3. Install GitLab. A Complete! message at the end of the output indicates that the installation is successful.

    sudo yum install -y gitlab-jh
  4. Configure the external access URL and start GitLab.

    Replace ECS_PUBLIC_IP with the public IP address of the ECS instance.

    sudo EXTERNAL_URL="http://ECS_PUBLIC_IP" gitlab-ctl reconfigure
    The initial run takes about 5 to 10 minutes to complete.
  5. Verify the service status.

    sudo gitlab-ctl status

    The output shows that the puma, sidekiq, nginx, postgresql, redis, and prometheus processes are all in the run state, indicating that GitLab has started successfully.

CentOS 7.x

  1. Connect to a Linux instance by using Workbench.

  2. Install the required dependencies.

    sudo yum install -y curl policycoreutils-python openssh-server
  3. Add the GitLab package repository.

    curl -fsSL https://get.gitlab.cn | sudo /bin/bash
    This step may fail due to network issues. If it does, try again.

    When the output contains the keyword Successfully added gitlab-jh repo, the GitLab package repository is installed.

  4. Install and start GitLab.

    Replace ECS_PUBLIC_IP with the public IP address of the instance where GitLab is installed and run the following:

    sudo EXTERNAL_URL="http://ECS_PUBLIC_IP" yum install -y gitlab-jh
    The initial run takes about 5 to 10 minutes to complete.
  5. Verify the service status.

    sudo gitlab-ctl status

    The output shows that processes such as puma, sidekiq, nginx, postgresql, redis, and prometheus are all in the run state, which indicates that GitLab has started successfully.

Ubuntu

  1. Connect to a Linux instance by using Workbench.

  2. Install the required dependencies.

    sudo apt-get update
    sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
  3. Configure the software source mirror for JiHu GitLab.

    curl -L get.gitlab.cn | bash

    If the output contains Successfully added gitlab-jh repo, the GitLab software package repository is installed.

  4. Install and start GitLab.

    Replace ECS_PUBLIC_IP with the public IP address of your GitLab instance.

    sudo EXTERNAL_URL="http://ECS_PUBLIC_IP" apt-get install -y gitlab-jh
  5. Verify the service status.

    sudo gitlab-ctl status

    The output shows that processes such as puma, sidekiq, nginx, postgresql, and redis are all in the run status. This indicates that GitLab has started successfully.

GitLab Community Edition

On Alibaba Cloud Linux 3, you can only install JiHu GitLab using an installation package. To install GitLab Community Edition on Alibaba Cloud Linux 3, use a Docker image instead.

CentOS 7.x

  1. Connect to a Linux instance by using Workbench.

  2. Add the GitLab package repository.

    curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
  3. Install the required dependencies.

    sudo yum install -y curl policycoreutils-python openssh-server
  4. Install GitLab Community Edition. The message Complete! indicates that the installation is successful.

    sudo EXTERNAL_URL="http://ECS_PUBLIC_IP" yum install -y gitlab-ce

    Replace <ECS_PUBLIC_IP> with the public IP address of the ECS instance where GitLab is installed. You must retain the http:// or https:// prefix. Otherwise, the gitlab-ctl reconfigure command fails because the external_url parameter is missing a protocol.

  5. Verify the service status.

    sudo gitlab-ctl status

    The output shows that processes such as puma, sidekiq, nginx, postgresql, redis, and prometheus are all in the run state, indicating that GitLab has started successfully.

Ubuntu

  1. Connect to a Linux instance by using Workbench.

  2. Install the required dependencies.

    sudo apt-get update
    sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
  3. Add the GitLab software package repository. When the output is The repository is setup! You can now installpackages., the GitLab software package repository is installed.

    sudo curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
    This step may fail due to network issues. If it does, try again.
  4. Refresh the package list.

    sudo apt-get update
  5. Install GitLab. A final output of Complete! indicates a successful installation.

    sudo EXTERNAL_URL="http://ECS_PUBLIC_IP" apt-get install -y gitlab-ce

    Replace <ECS_PUBLIC_IP> with the public IP address of the ECS instance where GitLab is installed. You must retain the http:// or https:// prefix. Otherwise, the gitlab-ctl reconfigure command will report an error because the external_url parameter is missing a protocol.

  6. Verify the service status.

    sudo gitlab-ctl status

    The output shows that processes such as puma, sidekiq, nginx, postgresql, redis, and prometheus are all in the run state, which indicates that GitLab has started successfully.

ECS extension

An ECS extension is a plug-in that extends the functionality of ECS instances. It installs JiHu GitLab by default on Alibaba Cloud Linux 3 and GitLab Community Edition on other supported systems.

  1. Log on to the ECS console and go to the Extensions tab of the target instance.

  2. Find the GitLab extension in the list and complete the installation. For detailed steps, see OOS extension. The supported OS versions are subject to what is displayed in the console.

    Supported OS versions currently include Ubuntu 24.04, Ubuntu 22.04, Ubuntu 20.04, CentOS 7.9, CentOS 7.8, CentOS 7.7, and Alibaba Cloud Linux 3.2. Note that Alibaba Cloud Linux 3.2 uses JiHu GitLab. To install the extension, go to the Server Management > Extensions page from the left-side navigation pane. Click GitLab to view its details, and then click Install Extension.

  3. After the extension status changes to successful, remotely connect to the ECS instance and run the following command to check the GitLab service status.

    sudo gitlab-ctl status

    A run status for processes such as puma, sidekiq, nginx, postgresql, and redis indicates that GitLab has started successfully.

Docker image

  1. Connect to a Linux instance by using Workbench.

  2. Install Docker.

    Docker Compose is not required.
  3. Create mount directories on the host. These directories persist GitLab configuration files, logs, and data outside the container.

    sudo mkdir -p /srv/gitlab 
  4. Set the environment variable $GITLAB_HOME.

    export GITLAB_HOME=/srv/gitlab
  5. Run the following command to start the GitLab container.

    Important

    Pulling images from Docker Hub can be slow or fail due to network issues. You can use the official image accelerator provided by Alibaba Cloud Container Registry (ACR) to speed up downloads. For instructions, see Accelerate the download of official images.

    GitLab Community Edition

    sudo docker run --detach \
      --hostname gitlab.example.com \
      --publish 443:443 --publish 80:80 --publish 2222:22 \
      --name gitlab \
      --restart always \
      --volume $GITLAB_HOME/config:/etc/gitlab \
      --volume $GITLAB_HOME/logs:/var/log/gitlab \
      --volume $GITLAB_HOME/data:/var/opt/gitlab \
      --shm-size 256m \
      gitlab/gitlab-ce:latest

    Parameter

    Description

    hostname

    The hostname for the container. Set this to the public IP address of your ECS instance.

    publish 443:443

    Map port 443 of the host to port 443 of the container for HTTPS access. If the host port is already in use, replace it with a non-standard port, such as publish 8443:443.

    Note

    If you switch to a non-standard port, you must add an inbound security group rule to allow traffic on that port (for example, 8443). For more information, see Add a security group rule. Security group rules are stateful, so you only need to configure an inbound rule. The system automatically allows the corresponding outbound response traffic.

    publish 80:80

    Map port 80 on the host to port 80 in the container for HTTP access. If the host port is already in use, replace it with a non-standard port, such as publish 8080:80.

    Note

    If you switch to a non-standard port, you must add an inbound security group rule to allow traffic on that port (for example, 8080). For more information, see Add a security group rule. Security group rules are stateful, so you only need to configure an inbound rule. The system automatically allows the corresponding outbound response traffic.

    publish 2222:22

    Maps host port 2222 to container port 22 for SSH-based Git clone, push, and pull operations.

    Note
    • The SSH service starts by default on an ECS instance and uses port 22.

    • If you switch to a non-standard port like 2222, you must first add an inbound rule to the security group to allow traffic on that port, and then modify the SSH port number in the gitlab.rb file.

    The following table shows the mapping between host paths and container paths.

    ECS path

    Container path

    Description

    $GITLAB_HOME/data

    /var/opt/gitlab

    Stores application data.

    $GITLAB_HOME/logs

    /var/log/gitlab

    Stores GitLab log files.

    $GITLAB_HOME/config

    /etc/gitlab

    Stores GitLab configuration files.

    JiHu GitLab

    sudo docker run --detach \
      --hostname gitlab.example.com \
      --publish 443:443 --publish 80:80 --publish 2222:22 \
      --name gitlab \
      --restart always \
      --volume $GITLAB_HOME/config:/etc/gitlab \
      --volume $GITLAB_HOME/logs:/var/log/gitlab \
      --volume $GITLAB_HOME/data:/var/opt/gitlab \
      --shm-size 256m \
      registry.gitlab.cn/omnibus/gitlab-jh:latest

    Parameter

    Description

    hostname

    The hostname for the container. Set this to the public IP address of your ECS instance.

    publish 443:443

    Map port 443 of the host to port 443 of the container for HTTPS access. If the host port is already in use, replace it with a non-standard port, such as publish 8443:443.

    Note

    If you switch to a non-standard port, you must add an inbound security group rule to allow traffic on that port (for example, 8443). For more information, see Add a security group rule. Security group rules are stateful, so you only need to configure an inbound rule. The system automatically allows the corresponding outbound response traffic.

    publish 80:80

    Map port 80 on the host to port 80 in the container for HTTP access. If the host port is already in use, replace it with a non-standard port, such as publish 8080:80.

    Note

    If you switch to a non-standard port, you must add an inbound security group rule to allow traffic on that port (for example, 8080). For more information, see Add a security group rule. Security group rules are stateful, so you only need to configure an inbound rule. The system automatically allows the corresponding outbound response traffic.

    publish 2222:22

    Maps host port 2222 to container port 22 for SSH-based Git clone, push, and pull operations.

    Note
    • The SSH service starts by default on an ECS instance and uses port 22.

    • If you switch to a non-standard port like 2222, you must first add an inbound rule to the security group to allow traffic on that port, and then modify the SSH port number in the gitlab.rb file.

    The following table shows the mapping between host paths and container paths.

    ECS path

    Container path

    Description

    $GITLAB_HOME/data

    /var/opt/gitlab

    Stores application data.

    $GITLAB_HOME/logs

    /var/log/gitlab

    Stores GitLab log files.

    $GITLAB_HOME/config

    /etc/gitlab

    Stores GitLab configuration files.

  6. Check the container status.

    sudo docker ps -a

    A (healthy) status in the STATUS column indicates that the GitLab container is running normally.

    [ecs-user@iZ2zeee22a96g       ~]$ sudo docker ps -a
    CONTAINER ID   IMAGE                     COMMAND             CREATED      STATUS                PORTS                                                                                                         NAMES
    75b3bc5de483   gitlab/gitlab-ce:latest   "/assets/wrapper"   2 hours ago  Up 2 hours (healthy)  0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:5000->22/tcp, :::5000->22/tcp, 0.0.0.0:8080->80/tcp, :::8080->80/tcp   gitlab

    For a more thorough check, inspect the GitLab processes inside the container:

    sudo docker exec gitlab gitlab-ctl status

    Processes such as puma, sidekiq, nginx, postgresql, and redis should all be in the run state, indicating that GitLab inside the container is running.

Access the GitLab admin page

  1. Enter the following URL in your browser: http://${ECS public IP address}.

    Important

    If you installed GitLab using a Docker image and mapped the default HTTP port 80 to a non-standard port, append the new port number to the URL.

  2. For your first login, use the username root and obtain the password as follows.

    On your ECS instance, run the command for your installation method:

    • Linux installation package: sudo cat /etc/gitlab/initial_root_password

    • Docker installation: sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password

    The output is similar to the following. The value after the Password field is the initial login password for GitLab.

    [test@iZuf63zs0dn0cxxx          ~]$ sudo cat /etc/gitlab/initial_root_password
    # WARNING: This value is valid only in the following conditions
    #       1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`), it was provided before database was seeded for the first time
    (usually, the first reconfigure run).
    #       2. Password hasn't been changed manually, either via UI or via command line.
    #
    #       If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
    Password: nB9P+4UUY2yx8Gp3BYgwQpKSfdo4wh11DpQH_
    # NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
    Important

    For security reasons, this file is automatically deleted after 24 hours. Change the initial password immediately after your first sign-in. For instructions, see reset_user_password.

  3. Go to the Admin page.

    At the top of the page, click Menu and select Admin.

  4. On the Users>Pending approval page, approve new user sign-up requests. For details on managing projects and users, see admin_area.

Note

This example shows how to upload a file to a GitLab repository. For more information about GitLab operations such as common commands, data backup, configuration, user management, service integration, and troubleshooting, see the documentation for JiHu GitLab and GitLab Community Edition.

Register a user and set up passwordless access

  1. Go to the GitLab page. Click Register now under the Sign in button to create a new user. After a GitLab administrator approves your request, sign in to GitLab with the new account.

  2. Generate a key pair on your local machine:

    ssh-keygen

    The command prompts you to enter a directory to save the key pair (the default is .ssh/id_rsa in your home directory, for example, /home/test/.ssh/id_rsa) and a passphrase. You can enter custom values or press Enter to accept the defaults.

    The output is similar to the following:

    [test@iZuf63zs0dn0qxxx : ~]$ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/test/.ssh/id_rsa):
    Created directory '/home/test/.ssh'.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /home/test/.ssh/id_rsa.
    Your public key has been saved in /home/test/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:c8wCYK16ByqC8jEWaL9G/2gkWVe3lQUaens xxx test@iZuf63zs0dn0xxx
    The key's randomart image is:
    +---[RSA 2048]----+
    |   o.    .+o.|
    |    . ..  ...0+.. |
    |  .   . ...oo.+ .|
    |... o. o o..oE.o |
    |o .+o.. S +..oo  |
    |= *=...  +  .+   |
    |o+.+=.    .      |
    |  .o o.          |
    |   ....          |
    +----[SHA256]-----+
  3. View and copy the contents of the id_rsa.pub public key file.

    cat ~/.ssh/id_rsa.pub

    The output is similar to the following:

    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQVwWjF3KXmI549jDI0fuCgl+syJjjn55iMUDRRiCd/B+9TwUda3l9WXH5i7RU53QGRCsDVFZxixLOlmXr9E3VSqkf8xXBnHs/5E2z5PIOCN0nxfB9xeA1db/QxPwK4gkHisep+eNHRn9x+DpCYDoSoYQN0nBg+H3uqfOqL42mJ+tqSfkyqbhjBf1kjtDTlBfVCWtI0siu7owm+c65+8KNyPlj5/0AyJ4Aqk1OX2jv+YE4nTipucn7rHwWuowasPU86l+uBsLNwOSb+H7loJvQyhEINX2FS1KnpRU+ld20t07n+N3ErfX5xBAGfxXpoN9BKKSP+RT7rvTeXTVE**** test@iZuf63zs0dn0qccsisy****
  4. Add the public key to your GitLab account as an SSH key to enable passwordless access.

    1. Click your profile picture in the upper-right corner, and then click Profile.

      In earlier versions of GitLab, this menu item was named Edit profile.
    2. In the left navigation bar, click SSH Keys. Paste the content of the public key file id_rsa.pub into the Key text box, and then click Add key.

    3. After you add the SSH key, the page displays key details including its content, fingerprint (MD5 and SHA256), and metadata such as creation and expiration dates.

Create a project and host code

Create a new project

  1. On the GitLab home page, click the New Project button on the right, and then click Create blank project.

  2. On the Create blank project page, set the Project name and Project URL, and then click the Create project button at the bottom of the page. This example uses a project named mywork.

  3. Return to the project page and copy the SSH clone URL. You will need this URL to clone the repository.

    Important

    The SSH clone URL on the project page uses gitlab.example.com as the default host (the built-in default hostname in GitLab). Cloning directly will fail due to a DNS resolution error. Before you clone, manually replace the host with the public IP of your ECS instance or a custom domain.

    To make the project page display the correct host, configure gitlab_rails['gitlab_shell_ssh_host'] in /etc/gitlab/gitlab.rb and then run sudo gitlab-ctl reconfigure. For more information, see Configuring the external URL for GitLab.

Clone the remote repository

  1. Install Git on your local machine:

    sudo yum install git
  2. Configure your local Git identity:

    1. Set your Git username:

      git config --global user.name "testname" 
    2. Set your Git email address:

      git config --global user.email "abc@example.com" 
  3. Clone the project to your local machine.

    1. Run git clone with the SSH clone URL. Git automatically creates a directory named after the repository and downloads its contents.

      git clone ${SSH URL}

      If you installed GitLab using a Docker image, prepend the ssh:// prefix to the URL and specify the port mapped in the docker run command. For example:

      Important

      To avoid modifying the SSH URL, modify the gitlab_rails['gitlab_shell_ssh_port'] parameter so that the GitLab page displays the correct port. For more information, see What do I do if port 22 is already in use when I use Docker to start GitLab?.

      git clone ssh://git@{IP_address_or_domain_name}:{SSH_port}/root/mywork
      [ecs-user@iZ2zefuyca xxx ~]$ git clone git@59.xxx.xxx.xxx:root/mywork.git
      Cloning into 'mywork'...
      The authenticity of host '59.xxx.xxx.xxx (59.xxx.xxx.xxx)' can't be established.
      ECDSA key fingerprint is SHA256:I4eX9gjdR2dwOBmI5xerO+dTnJOZ/xxx.
      ECDSA key fingerprint is MD5:18:54:b5:be:b2:6d:e9:25:c1:4d:84:89:2f:b5:13:d1.
      Are you sure you want to continue connecting (yes/no)? yes
      Warning: Permanently added '59.xxx.xxx.xxx' (ECDSA) to the list of known hosts.
      remote: Enumerating objects: 3, done.
      remote: Counting objects: 100% (3/3), done.
      remote: Compressing objects: 100% (2/2), done.
      remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
      Receiving objects: 100% (3/3), done.
    2. Change to the project directory:

      cd mywork/ 
    3. Check the current branch. By default, this is the main branch.

      git branch

Create a new branch and modify a file

Create a new local branch to modify files.

  1. Create a branch named example:

     git checkout -b example     
  2. Create a file named test.txt and write the content Hello World! into it:

    echo "Hello world!" > test.txt

Commit and push changes

Push the new example branch to the remote repository.

  1. Add the test.txt file to the staging area:

    git add test.txt
  2. Check the status of your changes:

    git status

    The output is as follows:

    On branch example
    Changes to be committed:
      (use "git restore --staged <file>..." to unstage)
            new file:   test.txt
  3. Commit the staged file test.txt:

    git commit -m "Test commit"
  4. The example branch currently exists only locally. Push the branch to the GitLab repository to make it accessible to others:

    git push origin example
  5. After you push to the GitLab repository, other users can view the new branch.

    On the code repository page, click the branch selector in the upper-left corner. You can see the pushed example branch in the Branches list.

Merge changes

Merge the changes from your local example branch into the main branch, and then push the merged main branch to the remote repository.

  1. Switch to the main branch:

    git checkout main
  2. Merge the example branch into the main branch:

    git merge example
  3. Push the merged main branch to the GitLab repository:

    git push
  4. The changes are now on the main branch in the GitLab repository.

    In the main branch, the test.txt file contains Hello world!.

Next steps

Email notifications

GitLab uses a mail transfer agent to send email notifications for project updates, password resets, and other events. SMTP services typically use port 25, but Alibaba Cloud restricts outbound traffic on this port for ECS instances by default. We recommend using an SSL-encrypted port such as 465 for outgoing emails. For a list of commonly used ports, see Commonly used ports. To configure SMTP, follow these steps:

  1. Configure an external SMTP server.

  2. Verify the SMTP configuration.

    1. Run the gitlab-rails console command to enter the Rails console.

    2. Run the following command to send a test email:

      Notify.test_email('destination_email@address.com', 'Message Subject', 'Message Body').deliver_now
    3. Sign in to the destination mailbox to check for the test email, or run sudo tail -f /var/log/mail.log on the ECS instance to view the mail log.

Repository data backup

Domain name setup

Accessing your GitLab site by IP address is less secure than using a domain name. If you have or want to register a domain name for your GitLab site, follow these steps.

  1. Register a domain name.

  2. Complete an ICP filing for your domain name.

    If your domain name points to a website hosted on an Alibaba Cloud server in the Chinese mainland, you must complete an ICP filing. For first-time filings, see ICP filing process. For other scenarios, see ICP filing process.

  3. Set up DNS resolution to allow external users to access your GitLab site by domain name.

    DNS resolution is required to access your website by domain name. For instructions, see Beginner's guide to Alibaba Cloud DNS.

  4. Enable HTTPS. You can use a free service, such as Let's Encrypt automatic HTTPS, or a paid service, such as Enable HTTPS for a website by using a commercial certificate.

  5. Add a security group rule: In the instance's security group, add an inbound rule. For security reasons, we recommend that you open ports only to authorized IP addresses.

    • Installation package or extension: Port 443 (HTTPS).

    • Docker image: The host HTTPS port specified in the docker run command.

  6. Modify the external_url parameter in gitlab.rb. Your configuration should resemble the following example.

FAQ

Installation failure on Alibaba Cloud Linux 3: Out of memory allocating 18446744071562068992 bytes!

Symptom: After you add the repository using curl -fsSL https://get.gitlab.cn | sudo /bin/bash, running sudo yum install -y gitlab-jh or sudo yum makecache aborts the process with an Out of memory allocating 18446744071562068992 bytes! error, even though free -h shows plenty of free memory.

Cause: Alibaba Cloud Linux 3 includes the librepo 1.14.x series. You can check your version by running rpm -q librepo. When parsing the JiHu GitLab repository metadata, this version of librepo encounters an integer overflow if the <open-size> field value exceeds INT32_MAX. Consequently, glib misinterprets this as an impossible memory allocation request and terminates the process. The number 18446744... is a signature of a signed integer overflow, not an actual physical memory shortage.

Solution: Install the RPM package manually to bypass the yum parsing of the gitlab-jh repository metadata. For detailed steps, see Install GitLab and choose the package installation method.

Server is slow or unreachable

Port 22 is in use during Docker startup

The SSH service is enabled by default on an ECS instance and occupies port 22. When installing GitLab with a Docker image, you must map host port 22 to a different port and update the gitlab_rails['gitlab_shell_ssh_port'] parameter:

  1. When you start the Docker container, specify a non-standard port, for example, publish 2222:22.

  2. Edit the GitLab configuration file.

    1. Run sudo docker exec -it gitlab /bin/bash to open a shell inside the container.

    2. Edit the /etc/gitlab/gitlab.rb file.

    3. Set gitlab_rails['gitlab_shell_ssh_port'] = 2222.

    4. Run gitlab-ctl reconfigure to apply the new configuration.

  3. Open the project page to verify the configuration.

    Click the Clone button. In the drop-down panel, check the Clone with SSH section. Confirm that the SSH clone URL uses port 2222 (for example, ssh://git@<domain>:2222/<project_path>). This confirms that the custom SSH port is working.