GitLabのFreeBSDへのインストールが,噂以上に難しかった件について(2)

GitLabのFreeBSDへのインストールが,噂以上に難しかった件について - なぜか数学者にはワイン好きが多い

git本体の次は,Rubyを準備します.

Ruby

% pkg info -g ruby\*
ruby-1.9.3.484_2,1
ruby19-gems-1.8.29
ruby20-2.0.0.353_6,1
rubygem-test-unit-2.5.5

Ruby19とRuby20が入ってるね.
% pkg search -x '^ruby[0-9]{2}-[0-9]'
ruby20-2.0.0.481,1
ruby21-2.1.2,1

パッケージではもうRuby19は無いのかも.Ruby21を入れてメインにしようね.

% ruby --version
ruby 1.9.3p484 (2013-11-22 revision 43786) [amd64-freebsd10]

今はメインが19になっている.

# pkg install ruby21
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
pkg: docbook has a missing dependency: docbook500
pkg: plexhometheater has a missing dependency: lame
The following 1 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        ruby21: 2.1.2,1

The process will require 24 MB more space.
5 MB to be downloaded.

Proceed with this action? [y/N]: y
Fetching ruby21-2.1.2,1.txz: 100%    5 MB 881.3k/s    00:06    
Checking integrity... done (0 conflicting)
[1/1] Installing ruby21-2.1.2,1: 100%

rubyコマンドはruby19のハードリンクになってるね.

# ls -l /usr/local/bin/ruby*
-rwxr-xr-x  2 root  wheel  5688  6月  1 01:50 /usr/local/bin/ruby
-rwxr-xr-x  2 root  wheel  5688  6月  1 01:50 /usr/local/bin/ruby19
-rwxr-xr-x  1 root  wheel  5720  7月  6 06:42 /usr/local/bin/ruby20
-rwxr-xr-x  1 root  wheel  5720  8月 21 17:58 /usr/local/bin/ruby21

ruby21のハードリンクにしてしまおう.

# rm -v /usr/local/bin/ruby
/usr/local/bin/ruby
# ln -v /usr/local/bin/ruby21 /usr/localbin/ruby              
/usr/local/bin/ruby => /usr/local/bin/ruby21
# ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [amd64-freebsd10]

入っていなかったら,Bundlerもいれておこうね.

% gem install bundler --no-ri --no-rdoc

System User

専用のユーザを作ろうね.

# adduser 
Username: git
Full name: GitLab
Uid (Leave empty for default): 
Login group [git]: 
Login group is git. Invite git into other groups? []: 
Login class [default]: 
Shell (sh csh tcsh git-shell bash rbash nologin) [sh]: tcsh
Home directory [/home/git]: 
Home directory permissions (Leave empty for default): 
Use password-based authentication? [yes]: no
Lock out the account after creation? [no]: 
Username   : git
Password   : <disabled>
Full Name  : GitLab
Uid        : 1003
Class      : 
Groups     : git 
Home       : /home/git
Home Mode  : 
Shell      : /bin/tcsh
Locked     : no
OK? (yes/no): yes
adduser: INFO: Successfully added (git) to the user database.
Add another user? (yes/no): no
Goodbye!

適当.
まぁ,これはあとからいくらでも変えられるし.

Database

データベースが必要なんだね.
PostgreSQLが大推奨だそうなので,従うよ.

#### Install the database packages
# pkg install postgresql93-server
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 2 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        postgresql93-server: 9.3.5
        postgresql93-client: 9.3.5

The process will require 25 MB more space.
5 MB to be downloaded.

Proceed with this action? [y/N]: y
Fetching postgresql93-server-9.3.5.txz: 100%    3 MB   1.1M/s    00:03    
Fetching postgresql93-client-9.3.5.txz: 100%    2 MB   1.0M/s    00:02    
Checking integrity... done (0 conflicting)
[1/2] Installing postgresql93-client-9.3.5: 100%
===> Creating users and/or groups.
Creating group 'pgsql' with gid '70'.
Creating user 'pgsql' with uid '70'.

  =========== BACKUP YOUR DATA! =============
  As always, backup your data before
  upgrading. If the upgrade leads to a higher
  minor revision (e.g. 8.3.x -> 8.4), a dump
  and restore of all databases is
  required. This is *NOT* done by the port!

  Press ctrl-C *now* if you need to pg_dump.
  ===========================================
[2/2] Installing postgresql93-server-9.3.5: 100%
# emacs -nw /etc/rc.conf

postgresql_enable="YES"

# /usr/local/etc/rc.d/postgresql start
postgres cannot access the server configuration file "/usr/local/pgsql/data/postgresql.conf": No such file or directory
pg_ctl: could not start server
Examine the log output.

おっと.イニシャライズ忘れたよ.
# /usr/local/etc/rc.d/postgresql initdb

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/bin/postgres -D /usr/local/pgsql/data
or
    /usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

#  /usr/local/bin/pg_ctl -D /usr/local/pgsql/data start
pg_ctl: rootでは実行できません
サーバプロセスの所有者となる(非特権)ユーザとして(例えば"su"を使用して)
ログインしてください。

おっと.rootじゃダメね.

# su pgsql
$ /usr/local/bin/pg_ctl -D /usr/local/pgsql/data start
サーバは起動中です。
$ LOG:  ending log output to stderr
HINT:  Future log output will go to log destination "syslog".

#### Login to PostgreSQL

$ psql -d template1
psql (9.3.5)
"help" でヘルプを表示します.

#### Create a user for GitLab.

template1=# CREATE USER git CREATEDB;
CREATE ROLE

#### Create the GitLab production database & grant all privileges on database

template1=# CREATE DATABASE gitlabhq_production OWNER git;
CREATE DATABASE

#### Quit the database session
template1=# \q
$ 
#### Try connecting to the new database with the new user
# su git
% psql -d gitlabhq_production
psql (9.3.5)
"help" ??????????.

gitlabhq_production=> 

最後,日本語が化けましたが気にしない.

ここまでで!