FreeBSD GitLab 설치

 

 

GitLab : https://about.gitlab.com/

Requirements : https://docs.gitlab.com/ce/install/requirements.html

 

 

locale 변경

locale 을 변경 하고 jail 에서 빠져나간후 다시 접속 하여 locale 을 확인 합니다.

이때 주의 할점은 :umask=022: 부분이 \ 를 추가 charset부분에도 \ 를 추가 해야 정상적으로 동작이 됩니다.

git /root > vi /etc/login.conf
        :umask=022:\
        :charset=ko_KR.UTF-8:\
        :lang=ko_KR.UTF-8


git /root > cap_mkdb /etc/login.conf
git /root > logout
root@BSD11:~ # qjail console git
Last login: Sun Sep 16 23:52:14 on pts/0
FreeBSD 11.1-RELEASE-p14 (GENERIC) #0: Thu Sep  6 05:04:10 UTC 2018

Welcome to your FreeBSD jail.
git /root > locale
LANG=ko_KR.UTF-8
LC_CTYPE="ko_KR.UTF-8"
LC_COLLATE="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_NUMERIC="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_MESSAGES="ko_KR.UTF-8"
LC_ALL=
git /root >

 

GitLab 설치

root@BSD11:~ # pkg update
root@BSD11:~ # pkg upgrade
root@BSD11:~ # pkg install www/gitlab-ce

~중략

===>   NOTICE:

This port is deprecated; you may wish to reconsider installing it:

Upstream no longer maintained, use devel/rubygem-webpacker-rails* instead.

It is scheduled to be removed on or after 2018-08-31.
Message from redis-4.0.11:

===>  CONFIGURATION NOTE:

      To setup "redis" you need to edit the configuration file:
      /usr/local/etc/redis.conf

      To run redis from startup, add redis_enable="YES"
      in your /etc/rc.conf.
Message from gitlab-ce-11.2.3:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv GITLAB vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Gitlab was installed successfully.

You now need to set up the various components of Gitlab, so please
follow the instructions in the guide at:

https://gitlab.fechner.net/mfechner/Gitlab-docu/blob/master/install/11.2-freebsd.md

If you just installed an major upgrade of GitLab, for example you
switched from 11.1.x to 11.2.x, please follow the instructions in the guide at:

https://gitlab.fechner.net/mfechner/Gitlab-docu/blob/master/update/11.1-11.2-freebsd.md

If you just installed an minor upgrade of GitLab please follow
the instructions in the guide at:

https://gitlab.fechner.net/mfechner/Gitlab-docu/blob/master/update/freebsd_patch_versions.md

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GITLAB ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
root@BSD11:~ #

 

ports 설치

최신 pkg 사용을 위하여 repo 변경

root@BSD11:~ # mkdir -p /usr/local/etc/pkg/repos
root@BSD11:~ # vi /usr/local/etc/pkg/repos/FreeBSD.conf


FreeBSD: {
  url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest"
}

 

PostgreSQL 의 경우 gitlab 설치시 postgresql95 client 가 설치됩니다.

동일한 버젼으로 설치를 진행 합니다.

root@BSD11:~ # pkg info |grep -i post
ghostscript9-agpl-base-9.24_2  PostScript and PDF interpreter
ghostscript9-agpl-x11-9.24     PostScript and PDF interpreter, X11 support
postgresql95-client-9.5.14     PostgreSQL database (client)
rubygem-gitlab-flowdock-git-hook-1.0.1 GitLab-patched Git Post-Receive hook for Flowdock
rubygem-multipart-post-2.0.0   Ruby Library that Use with Net::HTTP to do multipart form posts
rubygem-pg0-0.21.0             Ruby interface to PostgreSQL library
rubygem-pg018-0.18.4           Ruby interface to PostgreSQL library
rubygem-slack-notifier1-1.5.1  Ruby wrapper for posting to slack webhooks
root@BSD11:~ #

 

PostgreSQL 설치

root@BSD11:~ # pkg install postgresql95-server postgresql95-contrib


~중략
To set limits, environment stuff like locale and collation and other
things, you can set up a class in /etc/login.conf before initializing
the database. Add something similar to this to /etc/login.conf:
---
postgres:\
        :lang=en_US.UTF-8:\
        :setenv=LC_COLLATE=C:\
        :tc=default:
---
and run `cap_mkdb /etc/login.conf'.
Then add 'postgresql_class="postgres"' to /etc/rc.conf.

======================================================================

To initialize the database, run

  /usr/local/etc/rc.d/postgresql initdb

You can then start PostgreSQL by running:

  /usr/local/etc/rc.d/postgresql start

For postmaster settings, see ~pgsql/data/postgresql.conf

NB. FreeBSD's PostgreSQL port logs to syslog by default
    See ~pgsql/data/postgresql.conf for more info

NB. If you're not using a checksumming filesystem like ZFS, you might
    wish to enable data checksumming. It can only be enabled during
    the initdb phase, by adding the "--data-checksums" flag to
    the postgres_initdb_flags rcvar.  Check the initdb(1) manpage
    for more info and make sure you understand the performance
    implications.

======================================================================

To run PostgreSQL at startup, add
'postgresql_enable="YES"' to /etc/rc.conf
Message from postgresql95-contrib-9.5.14:

The PostgreSQL contrib utilities have been installed. Please see
/usr/local/share/doc/postgresql/contrib/README
for more information.
root@BSD11:~ #

 

postgresql /etc/rc.conf 등록 및 initdb 실행

initdb 실행시 정상적으로 실행이 되지 않습니다.

root@BSD11:~ # sysrc postgresql_enable=YES
postgresql_enable:  -> YES
root@BSD11:~ # 

root@BSD11:~ # service postgresql initdb
이 데이터베이스 시스템에서 만들어지는 파일들은 그 소유주가 "pgsql" id로
지정될 것입니다. 또한 이 사용자는 서버 프로세스의 소유주가 됩니다.

데이터베이스 클러스터는 다음 로케일으로 초기화될 것입니다.
  COLLATE:  C
  CTYPE:    ko_KR.UTF-8
  MESSAGES: ko_KR.UTF-8
  MONETARY: ko_KR.UTF-8
  NUMERIC:  ko_KR.UTF-8
  TIME:     ko_KR.UTF-8
initdb: "ko_KR.UTF-8" 로케일에 알맞은 전문검색 설정을 찾을 수 없음
기본 텍스트 검색 구성이 "simple"(으)로 설정됩니다.

Data page checksums are disabled.

/usr/local/pgsql/data 디렉터리 만드는 중 ...완료
하위 디렉터리 만드는 중 ...완료
max_connections 초기값을 선택하는 중 ...100
기본 shared_buffers를 선택하는 중... 128MB
selecting dynamic shared memory implementation ... posix
환경설정 파일을 만드는 중 ...완료
/usr/local/pgsql/data/base/1 안에 template1 데이터베이스를 만드는 중 ...완료
pg_authid 초기화 중 ...완료
의존성 정보 초기화 중 ...완료
시스템 뷰들을 만드는 중 ... 완료
시스템 개체들 설명 자료 입력 중 ...완료
collation 만드는 중 ... 완료
인코딩 변환규칙(conversion)들을 만드는 중 ...완료
사전을 만드는 중... 완료
내장개체들의 액세스 권한을 설정 중 ... 완료
information schema 만드는 중 ...완료
서버측 언어인 PL/pgSqL 불러오는 중 ... 완료
template1 데이터베이스 청소 중 ...완료
template1 데이터베이스를 template0 데이터베이스로 복사 중 ...완료
template1 데이터베이스를 postgres 데이터베이스로 복사 중 ...완료
syncing data to disk ... 완료

경고: 로컬 연결의 인증 방법으로 "trust" 방식을 지정했습니다.
이 값을 바꾸려면, pg_hba.conf 파일을 수정하든지,
다음번 initdb 명령을 사용할 때, -A 옵션 또는 --auth-local,
--auth-host 옵션을 사용해서 인증 방법을 지정할 수 있습니다.

작업완료. 이제 다음 명령을 이용해서 서버를 가동 할 수 있습니다:

    /usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l 로그파일 start

root@BSD11:~ #

 

postgresql 실행

git /root > service postgresql start
LOG:  could not create IPv6 socket: Protocol not supported
LOG:  ending log output to stderr
HINT:  Future log output will go to log destination "syslog".
git /root >

 

For PostgreqSQL < 9.6 execute:

blog 내용으로 설치 하였으면 해당 설정을 이용합니다. postgres user 로 설정 해야 합니다.

# create user git
# ATTENTION: for first installation superuser rights are needed; after installation this should be removed!
psql -d template1 -U pgsql -c "CREATE USER git CREATEDB SUPERUSER;"

# Create the GitLab production database & grant all privileges on database
psql -d template1 -U pgsql -c "CREATE DATABASE gitlabhq_production OWNER git;"

# Try connecting to the new database with the new user
psql -U git -d gitlabhq_production

# Connect as superuser to gitlab db and enable pg_trgm extension if not installed
psql -U pgsql -d gitlabhq_production -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"

 

For PostgreqSQL >= 9.6 execute:

# create user git
psql -d template1 -U postgres -c "CREATE USER git CREATEDB SUPERUSER;"

# Create the GitLab production database & grant all privileges on database
psql -d template1 -U postgres -c "CREATE DATABASE gitlabhq_production OWNER git;"

# Try connecting to the new database with the new user
psql -U git -d gitlabhq_production

# Connect as superuser to gitlab db and enable pg_trgm extension if not installed
psql -U postgres -d gitlabhq_production -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"

 

PostgreSQL 9.5 command

root@BSD11:~ # psql -d template1 -U pgsql -c "CREATE USER git CREATEDB SUPERUSER;"
CREATE ROLE
root@BSD11:~ # psql -d template1 -U pgsql -c "CREATE DATABASE gitlabhq_production OWNER git;"
CREATE DATABASE
root@BSD11:~ # psql -U git -d gitlabhq_production
gitlabhq_production=# \q
root@BSD11:~ # psql -U pgsql -d gitlabhq_production -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
CREATE EXTENSION

 

Redis 설정

root@BSD11:~ # echo 'unixsocket /var/run/redis/redis.sock' >> /usr/local/etc/redis.conf
root@BSD11:~ # echo 'unixsocketperm 770' >> /usr/local/etc/redis.conf
root@BSD11:~ # sysrc redis_enable=YES
redis_enable:  -> YES
root@BSD11:~ # service redis restart
redis not running? (check /var/run/redis/redis.pid).
Starting redis.
root@BSD11:~ # pw groupmod redis -m git

 

GitLab 설정

git 사용자 홈디렉토리를 변경 합니다.

root@BSD11:~ # vipw -d /etc
git:*:211:211::0:0:git user:/usr/local/git:/bin/sh
 
=> /usr/home 으로 변경합니다. 
git:*:211:211::0:0:git user:/usr/home/git:/bin/sh

 

git.yml 파일을 수정 합니다.

root@BSD11:~ # vi /usr/local/www/gitlab-ce/config/gitlab.yml
#    host: localhost
    host: gitlab.example.com 


root@BSD11:/usr/local/www/gitlab-ce # sysctl hw.ncpu
hw.ncpu: 2
root@BSD11:/usr/local/www/gitlab-ce #
root@BSD11:/usr/local/www/gitlab-ce # vi config/unicorn.rb
hw.ncpu 확인시 확인된 cpu 수로 worker 를 설정 2G 이상의 경우 worker default 3개로 사용
worker_processes 3 


root@BSD11:~ # su -l git -c "git config --global core.autocrlf input"
root@BSD11:~ # su -l git -c "git config --global gc.auto 0"
root@BSD11:~ # su -l git -c "git config --global repack.writeBitmaps true"
root@BSD11:~ # su -l git -c "git config --global receive.advertisePushOptions true"
root@BSD11:~ # su -l git -c "mkdir -p /usr/home/git/.ssh"

 

데이터 베이스 초기화 설정

yes 입력시 databasetable 을 생성 합니다.

root@BSD11:~ # chown git /usr/local/share/gitlab-shell
root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake gitlab:setup RAILS_ENV=production"

Do you want to continue (yes/no)? yes

root@BSD11:~ # chown root /usr/local/share/gitlab-shell

 

password 를 설정 합니다.

test1234

root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=test1234"

 

System infomation 확인

root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake gitlab:env:info RAILS_ENV=production"

System information
System:
Current User:   git
Using RVM:      no
Ruby Version:   2.4.4p296
Gem Version:    2.7.6
Bundler Version:1.16.2
Rake Version:   12.3.1
Redis Version:  4.0.10
Git Version:    2.18.0
Sidekiq Version:5.1.3
Go Version:     unknown

GitLab information
Version:        11.1.6
Revision:       Unknown
Directory:      /usr/local/www/gitlab-ce
DB Adapter:     postgresql
URL:            http://localhost
HTTP Clone URL: http://localhost/some-group/some-project.git
SSH Clone URL:  git@localhost:some-group/some-project.git
Using LDAP:     no
Using Omniauth: no

GitLab Shell
Version:        7.1.4
Repository storage paths:
- default:      /usr/home/git/repositories
Hooks:          /usr/local/share/gitlab-shell/hooks
Git:            /usr/local/bin/git
root@BSD11:~ #

 

Compile GetText PO files & Compile Assets

root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake gettext:compile RAILS_ENV=production"
root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake yarn:install gitlab:assets:clean gitlab:assets:compile RAILS_ENV=production NODE_ENV=production"

 

For PostgreSQL < 9.6 execute:

blog 에서는 PostgreSQL 9.5 를 이용함으로 아래 command 를 입력합니다.

psql -d template1 -U pgsql -c "ALTER USER git WITH NOSUPERUSER;"

 

For PostgreSQL >= 9.6 execute:

psql -d template1 -U postgres -c "ALTER USER git WITH NOSUPERUSER;"

 

PostgreSQL 9.5 command

root@BSD11:~ # psql -d template1 -U pgsql -c "ALTER USER git WITH NOSUPERUSER;"

 

gitlab 데몬 실행

root@BSD11:~ # sysrc gitlab_enable=YES
gitlab_enable:  -> YES

root@BSD11:~ # service gitlab start
Regenerate Gitlab Gemfile.lock
Regenerate Gitaly Gemfile.lock
Starting GitLab Unicorn
Starting GitLab Sidekiq
Starting GitLab Workhorse
Starting Gitaly
master failed to start, check stderr log for details
..
~중략
root@BSD11:~ #

 

Nginx 설치

설치시 아래와 같이 size mismatch 가 발생하면 pkg update -f  로 pkg 를 갱신 합니다. 

root@BSD11:~ # pkg install nginx
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        nginx: 1.14.0_11,2

Number of packages to be installed: 1

The process will require 1 MiB more space.
418 KiB to be downloaded.
[git] [1/1] Fetching nginx-1.14.0_11,2.txz: 100%  418 KiB 428.0kB/s    00:01
pkg: cached package nginx-1.14.0_11,2: size mismatch, fetching from remote
[git] Fetching nginx-1.14.0_11,2.txz: 100%  418 KiB 428.0kB/s    00:01
pkg: cached package nginx-1.14.0_11,2: size mismatch, cannot continue
root@BSD11:~ # pkg update -f

 

Nginx 설치

root@BSD11:~ # pkg install nginx

Message from nginx-1.14.0_11,2:

===================================================================
Recent version of the NGINX introduces dynamic modules support.  In
FreeBSD ports tree this feature was enabled by default with the DSO
knob.  Several vendor's and third-party modules have been converted
to dynamic modules.  Unset the DSO knob builds an NGINX without
dynamic modules support.

To load a module at runtime, include the new `load_module'
directive in the main context, specifying the path to the shared
object file for the module, enclosed in quotation marks.  When you
reload the configuration or restart NGINX, the module is loaded in.
It is possible to specify a path relative to the source directory,
or a full path, please see
https://www.nginx.com/blog/dynamic-modules-nginx-1-9-11/ and
http://nginx.org/en/docs/ngx_core_module.html#load_module for
details.

Default path for the NGINX dynamic modules is

/usr/local/libexec/nginx.
===================================================================

 

Nginx 설정

root@BSD11:~ # vi /usr/local/etc/nginx/nginx.conf


http {
    include       mime.types;
    include       /usr/local/www/gitlab-ce/lib/support/nginx/gitlab;

 

Nginx /etc/rc.conf 에 enable

root@BSD11:~ # sysrc nginx_enable=YES
nginx_enable:  -> YES

 

gitlab 설정변경 및 nginx 실행

root@BSD11:~ # vi /usr/local/www/gitlab-ce/lib/support/nginx/gitlab

  listen 0.0.0.0:80 default_server;
#  listen [::]:80 default_server;

git /root > service nginx stop
Stopping nginx.
Waiting for PIDS: 6103.
git /root >service nginx start
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.
git /root >


git /root > sockstat -4
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
www      nginx      4460  8  tcp4   10.0.0.1:80           *:*
root     nginx      4459  8  tcp4   10.0.0.1:80           *:*
redis    redis-serv 3675  6  tcp4   10.0.0.1:6379         *:*
pgsql    postgres   3566  8  udp4   10.0.0.1:18280        10.0.0.1:18280
pgsql    postgres   3565  8  udp4   10.0.0.1:18280        10.0.0.1:18280
pgsql    postgres   3564  8  udp4   10.0.0.1:18280        10.0.0.1:18280
pgsql    postgres   3563  8  udp4   10.0.0.1:18280        10.0.0.1:18280
pgsql    postgres   3562  8  udp4   10.0.0.1:18280        10.0.0.1:18280
pgsql    postgres   3560  4  tcp4   10.0.0.1:5432         *:*
pgsql    postgres   3560  8  udp4   10.0.0.1:18280        10.0.0.1:18280
git /root >

 

점검 실행

root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake gitlab:check RAILS_ENV=production"

 

Web 접속

 

Username : root

password: test1234

 

주의!!! Rebooting 시 gitlab 이 정상적으로 기동이 되지 않습니다.

수동으로 service gitlab start 로 실행 해줘야 합니다.

root@BSD11:~ # service gitlab status
Regenerate Gitlab Gemfile.lock
Regenerate Gitaly Gemfile.lock
The GitLab Unicorn web server with pid 692 is running.
The GitLab Sidekiq job dispatcher is not running.
The GitLab Workhorse is not running.
Gitaly is not running.
root@BSD11:~ # service gitlab start
Regenerate Gitlab Gemfile.lock
Regenerate Gitaly Gemfile.lock
The Unicorn web server already running with pid 692, not restarting.
The Sidekiq job dispatcher is already running with pid 795, not restarting
The GitLab Workhorse is already running with pid 749, not restarting
Gitaly is already running with pid 752, not restarting

The GitLab Unicorn web server with pid 692 is running.
The GitLab Sidekiq job dispatcher with pid 795 is running.
The GitLab Workhorse with pid 749 is running.
Gitaly with pid 752 is running.
GitLab and all its components are up and running.
root@BSD11:~ #

 

 

 

Last modified: 2019-09-26

Author

Comments

Write a Reply or Comment