Home > Article > Development Tools > How to build your own Gitlab server on NUC
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
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
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
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'
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
After waiting for the installation to complete, run the following command to start the Gitlab server:
sudo gitlab-ctl reconfigure sudo gitlab-ctl restart
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 { } }
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
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!