Home Development Tools git How to build your own Gitlab server on NUC

How to build your own Gitlab server on NUC

Mar 31, 2023 am 09:19 AM

In the field of software development, version control is a very important tool. It can help teams collaborate among developers distributed in different geographical locations to develop, debug and test code on different versions and branches. Git is one of the most popular open source version control tools. Among individual developers or small teams, free Gitlab can help them implement their own version control system. This article will introduce how to build your own Gitlab server on NUC.

NUC Introduction

Intel NUC (Next Unit of Computing) is a mini computer that is very small in size but very powerful in configuration. NUC's high-performance processor, memory, hard disk, and network interfaces are the main features of these devices.

Build environment

Before starting to build our Gitlab server, we need to prepare a NUC running environment. We require this environment to have the following characteristics:

Operating system: Ubuntu 18.04.5 LTS

Memory: at least 4GB

Hard disk: at least 60GB

Network: Have a public IP address and be able to access ports 22 and 80

Configuration steps

Step 1: Update the software package

Before we start installing Gitlab, we need Update software packages:

sudo apt update
sudo apt upgrade
Copy after login

Step 2: Install necessary software

Before installing Gitlab, we need to install Git, PostgreSQL and Nginx:

sudo apt install -y curl openssh-server ca-certificates
sudo apt install -y postfix
sudo apt install -y git-core
sudo apt install -y postgresql postgresql-contrib
sudo apt install -y nginx
Copy after login

Installed these software packages After that, we need to configure the PostgreSQL database and Nginx server.

Step 3: Configure PostgreSQL database

In Gitlab, we use PostgreSQL as the database engine. We need to create a user running Gitlab, and a database named gitlabhq_production.

sudo su - postgres
createuser --interactive
createdb gitlabhq_production
Copy after login

After creating the database, we need to configure it to Gitlab. We open and edit the configuration file /etc/gitlab/gitlab.rb. Find the following statement in it, uncomment it, and modify it to the following content:

## GitLab Postgres connection settings
gitlab_rails['db_adapter'] = 'postgresql'
gitlab_rails['db_encoding'] = 'unicode'
gitlab_rails['db_host'] = '127.0.0.1'
gitlab_rails['db_port'] = '5432'
gitlab_rails['db_username'] = 'git'
gitlab_rails['db_password'] = 'password'
gitlab_rails['db_database'] = 'gitlabhq_production'
Copy after login

Step 4: Install Gitlab

We can download the Gitlab Community Edition from the Gitlab official website:

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt-get install gitlab-ce
Copy after login

After waiting for the installation to complete, run the following command to start the Gitlab server:

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
Copy after login

Step 5: Configure Nginx

Gitlab uses Nginx as the Web server. Here we need to modify the Nginx configuration file /etc/nginx/sites-available/gitlab:

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/gitlab
sudo nano /etc/nginx/sites-available/gitlab

## 修改 Gitlab 配置文件中的内容如下 ##
upstream gitlab-workhorse {
  server unix:/var/opt/gitlab/gitlab-workhorse/socket fail_timeout=0;
}

server {
    listen 80;
    server_name yourdomain.com;
    server_tokens off;

    client_max_body_size 250m;

    location / {
        proxy_pass http://gitlab-workhorse;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_read_timeout 300;
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
Copy after login

After the modification is completed, run the following command to activate the configuration file:

sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Copy after login

Finally, we open the browser and visit the URL where Gitlab runs on NUC: http://yourdomain.com.

Conclusion

In this article, we learned how to set up our own Gitlab server on NUC. We first prepared a NUC environment running Ubuntu 18.04.5 LTS, then installed the necessary packages, configured a PostgreSQL database and Nginx server, installed Gitlab Community Edition, and configured it to run on the NUC. Now we can allow our teams to share code on their own servers.

The above is the detailed content of How to build your own Gitlab server on NUC. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is GitHub difficult to learn? Is GitHub difficult to learn? Apr 02, 2025 pm 02:45 PM

GitHub is not difficult to learn. 1) Master the basic knowledge: GitHub is a Git-based version control system that helps track code changes and collaborative development. 2) Understand core functions: Version control records each submission, supporting local work and remote synchronization. 3) Learn how to use: from creating a repository to push commits, to using branches and pull requests. 4) Solve common problems: such as merge conflicts and forgetting to add files. 5) Optimization practice: Use meaningful submission messages, clean up branches, and manage tasks using the project board. Through practice and community communication, GitHub’s learning curve is not steep.

Is Git the same as GitHub? Is Git the same as GitHub? Apr 08, 2025 am 12:13 AM

Git and GitHub are not the same thing. Git is a version control system, and GitHub is a Git-based code hosting platform. Git is used to manage code versions, and GitHub provides an online collaboration environment.

Does Microsoft own Git or GitHub? Does Microsoft own Git or GitHub? Apr 05, 2025 am 12:20 AM

Microsoft does not own Git, but owns GitHub. 1.Git is a distributed version control system created by Linus Torvaz in 2005. 2. GitHub is an online code hosting platform based on Git. It was founded in 2008 and acquired by Microsoft in 2018.

Should I put Git or GitHub on my resume? Should I put Git or GitHub on my resume? Apr 04, 2025 am 12:04 AM

On your resume, you should choose to write Git or GitHub based on your position requirements and personal experience. 1. If the position requires Git skills, highlight Git. 2. If the position values ​​community participation, show GitHub. 3. Make sure to describe the usage experience and project cases in detail and end with a complete sentence.

Should I start with Git or GitHub? Should I start with Git or GitHub? Apr 06, 2025 am 12:09 AM

Starting from Git is more suitable for a deep understanding of version control principles, and starting from GitHub is more suitable for focusing on collaboration and code hosting. 1.Git is a distributed version control system that helps manage code version history. 2. GitHub is an online platform based on Git, providing code hosting and collaboration capabilities.

What is Git in simple words? What is Git in simple words? Apr 09, 2025 am 12:12 AM

Git is an open source distributed version control system that helps developers track file changes, work together and manage code versions. Its core functions include: 1) record code modifications, 2) fallback to previous versions, 3) collaborative development, and 4) create and manage branches for parallel development.

How to use GitHub for HTML? How to use GitHub for HTML? Apr 07, 2025 am 12:13 AM

The reason for using GitHub to manage HTML projects is that it provides a platform for version control, collaborative development and presentation of works. The specific steps include: 1. Create and initialize the Git repository, 2. Add and submit HTML files, 3. Push to GitHub, 4. Use GitHubPages to deploy web pages, 5. Use GitHubActions to automate building and deployment. In addition, GitHub also supports code review, Issue and PullRequest features to help optimize and collaborate on HTML projects.

Why is GitLab better than GitHub? Why is GitLab better than GitHub? Apr 03, 2025 am 12:08 AM

GitLab is better for some developers and teams because it provides a complete DevOps toolchain and powerful CI/CD capabilities. 1. GitLab's CI/CD function is integrated within the platform, supporting full process automation from code submission to deployment. 2. Its server-side rendering technology improves page loading speed for large projects. 3. GitLab's permission management system is more flexible and supports fine-grained control.

See all articles