GitLab 6.8 をソースインストール

2014年5月22日(約10年前)の記事となっております。色々ご注意ください。

参考サイト

構成

  • yumでインストールしていたgitを削除
  • GitLabのデータベースはMySQL
  • GitLabのURLはSSL
  • webサーバはhttpd

Gitの準備

Gitアンインストール

yum remove git

※もともとyumのgitを使用していたためこの機会に最新版に変更

Gitインストール

cd /tmp
wget https://www.kernel.org/pub/software/scm/git/git-1.9.3.tar.gz
tar zxvf git-1.9.3.tar.gz
cd git-1.9.3
./configure --prefix=/usr/local
make prefix=/usr/local all
make prefix=/usr/local install

Gitインストール確認

git --version
bash: /usr/bin/git: そのようなファイルやディレクトリはありません
ln -s /usr/local/bin/git /usr/bin/git
git --version
git version 1.9.3

Gitの初期設定

git config --global user.name "GitLab"
git config --global user.email "gitlab@git.example.jp"

設定を確認

git config --list

Rubyの準備

ruby インストール

cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/ruby-2.1.2.tar.gz
tar zxvf ruby-2.1.2.tar.gz
cd ruby-2.1.2
./configure --disable-install-doc
make
make install
ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

bundlerのインストール

gem install bundler
gem install charlock_holmes --version '0.6.9'

Passengerのインストール

gem install passenger --no-rdoc --no-ri

PassengerのApache用モジュールのインストール

yum install curl-devel
yum install httpd-devel
yum install apr-devel
yum install apr-util-devel
passenger-install-apache2-module

完了後の内容を httpd.conf に記述 (下記は環境により変わる)

LoadModule passenger_module /usr/local/lib/ruby/gems/2.1.0/gems/passenger-4.0.33/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/2.1.0/gems/passenger-4.0.33
PassengerDefaultRuby /usr/local/bin/ruby

もう一度確認するときは、

passenger-install-apache2-module --snippet

ユーザー作成

useradd -c 'GitLab' -s /bin/bash git
su - git
cd /home/git
mkdir .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
chmod 700 .ssh

GitLab shellのインストール

 su git でgitユーザーとして実行

su - git
cd /home/git
git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell/
git checkout v1.9.4
git checkout -b v1.9.4
cp config.yml.example config.yml
vi config.yml

gitlab_url: "http://localhost/" をアクセスしたいURLに変更する

./bin/install

MySQL

MySQLをインストール

既にインストール済みのため省略

mysql -V
mysql Ver 14.14 Distrib 5.5.37, for Linux (x86_64) using readline 5.1

データベースを作成

CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'パスワード';
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';

Redisのインストール

yum install redis
/etc/init.d/redis start
chkconfig redis on

GitLabのインストール

su - git
cd /home/git
git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab
git checkout 6-8-stable

設定変更

cp config/gitlab.yml.example config/gitlab.yml
vi config/gitlab.yml

host, port, https, email_from, repos_path, ssh_port など

chown -R git log/
chown -R git tmp/
chmod -R u+rwX log/
chmod -R u+rwX tmp/
mkdir /home/git/gitlab-satellites
mkdir tmp/pids/
chmod -R u+rwX tmp/pids/
cp config/unicorn.rb.example config/unicorn.rb

GitLabのDB設定

cp config/database.yml.mysql config/database.yml
vi config/database.yml
< username: root
< password: "secure password"

Gemsのインストール

cd /home/git/gitlab
bundle install --deployment --without development test postgres

DBの初期化とセットアップ

bundle exec rake gitlab:setup RAILS_ENV=production

InitScriptのインストール

cd /home/git/gitlab
cp lib/support/init.d/gitlab /etc/init.d/gitlab
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
chmod +x /etc/init.d/gitlab
vi /etc/init.d/gitlab

※確認のみ

各種設定

ローテンションログの設定

cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

状態チェック

bundle exec rake gitlab:env:info RAILS_ENV=production

Assetsのビルド

bundle exec rake assets:precompile RAILS_ENV=production

起動とサービス登録

/etc/init.d/gitlab restart
chkconfig gitlab on

状態チェック

bundle exec rake gitlab:check RAILS_ENV=production
cd /home/git/gitlab
chown -R git:git .

httpの設定

httpdにVirtualHost の設定をする

ServerName 設定したURL

DocumentRoot /home/git/gitlab/public

他は通常のPassengerでの設定と同じ

apacheユーザーが/home/git にアクセスできるようにする

gpasswd -a apache git
chmod g+rX /home/git
cat /etc/group

設定 / 確認

cd /home/git/gitlab
vi /home/git/gitlab-shell/config.yml
vi config/gitlab.yml
/etc/init.d/gitlab restart
bundle exec rake gitlab:env:info RAILS_ENV=production
bundle exec rake gitlab:check RAILS_ENV=production

導入サポート・運用サポート

ということで宣伝です。

弊社ではPHP・MySQL・javascriptを使ったWebサイトを得意としています。
これらは2005年頃から触り続けてきていることもあり得意中の得意です。

Git については2012年頃から、GitLab は2014年頃 GitLab 6.8 のときから使い続けています。
ちなみに Github は取引先の都合で使用することはもちろんあります。

1日で完了する簡単なことから、半年・1年規模のものまで幅広く承っています。
特にプログラム開発が必要になるようなカスタマイズは遠慮なくご相談ください。

フロントの見た目に関わるところはデザイン会社が担当、裏方の技術部分を弊社が担当するケースもあり柔軟に対応することができます。

メールやSNSなどのメッセージで簡単に連絡いただいたあとで、電話していただけると確実です。(お問い合わせ