↑日記で日々積み重ねた情報をトップの「わんこのページ」にまとめています。

おのたく日記 [RDF] YouTubeも始めました→


2013-12-03(Tue) [長年日記]

[Debian] GitLabをDebian 7.0にインストールする

GitHubエンタープライズいいな~」って思っても気軽に使えなかったのだけど、GitLabなるPullRequestできるし、Wikiも、Issue Trackerも付いたものが有ることを知ったので、早速おうちサーバにGitLab 6.3をインストールする。

#実は、Redmineに色々Plugin追加していたら、Ruby1.8と1.9の狭間に入ってしまったのか、RedmineのDebianパッケージがインストールしても動かないということもあって、開発管理ツールを探していた。

おうちサーパは、いまはtestingのjessieやunstableのSidもちょっと入っているけど、基本はDebian 7.0 (wheezy) stable。

GitLabのDebianパッケージは無いので「Installation guide for a production serverを参考に手動インストールした。

GitLabインストールの前提パッケージインストール

エディターはemacsなので、エディターの設定は飛ばして、すでにインストールしてあるものも多いけど、まずはパッケージのインストール。

インストールガイドはphtyonとかgitとか慎重にイントールしていくけど、pyhtonは、python2.7パッケージをインストールすれば/usr/bin/python2もできるみたいで、Debian 7.0なら一気に行っても平気そう。

rubyは、1.9.3を要求されているけど、Debian 7.0はruby1.9.1が基本、ただruby 1.9.3パッケージなるものが有るなので入れておいた。

bundlerは、gemで作ることになっていたけど、debanパッケージがあるので、そちらを利用。

# aptitude install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python2.7 python-docutils git-core ruby1.9.3 bundler ruby1.9.1-dev

最後のruby1.9.1-devは、途中でbuild時に足りなかったので追加した。

ユーザは、すでにgitviewで使っている「git」をそのまま利用。

GitLab Shellのインストール

# cd ~git

# sudo -H -s -u git

% git clone https://github.com/gitlabhq/gitlab-shell.git

% cd gitlab-shell

% git -H git checkout v1.8.0

% cp config.yml.example config.yml

--config.ymlのgitlab_urlを正しいURLにする--

% ./bin/install

データベース準備

MySQLはすでに動いているので、開発ライブラリーだけインストールした。

# aptitude install -y libmysqlclient-dev

# mysql_secure_installation

# mysql -u root -p

--MySQLのパスワード入力--

mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY 'gitlabのパスワード';

mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;

mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost';

mysql> \q

# sudo -H -s -u git

% mysql -u git -p -D gitlabhq_production

--gitlabのパスワード入力--

mysql> /q

本体インストールと設定

インストールガイドに書いてあるとおりにインストール。ただし、log/とtmp/のchmodは、-Rをつけると.gitkeepまで変わってしまうので注意。

% cd

% git clone https://github.com/gitlabhq/gitlabhq.git gitlab

% cd gitlab

% git checkout 6-3-stable

% cp config/gitlab.yml.example config/gitlab.yml

% emacs config/gitlab.yml --host, emailアドレス修正--

% chown -R git log/ tmp/

% chmod u+rwx log/ tmp/

% mkdir ~/gitlab-satellites

% mkdir tmp/pids/ tmp/sockets/ public/uploads

% chmod u+rwx tmp/pids/ tmp/sockets/ public/uploads

% cp config/unicorn.rb.example config/unicorn.rb

% emacs config/unicorn.rb --port 8080が衝突していたら変える--

% cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

% git config --global user.name "GitLab"

% git config --global user.email "gitlab@localhost" --これはgitlab.ymlでのemailアドレスと同じにする--

% git config --global core.autocrlf input

% cp config/database.yml.mysql config/database.yml

% emacs config/database.yml --一番最初のブロックのgitlabのデータベースバスワードだけ変更--

% chmod o-rwx config/database.yml

% bundle install --deployment --without development test postgres aws

--結構時間かかる。ruby1.9.1-devパッケージが無くてエラーになった--

% git -H bundle exec rake gitlab:setup RAILS_ENV=production

--ここでデータを新しく作るか確認されるので"yes"--

% cp lib/support/init.d/gitlab /etc/init.d/gitlab

% sudo emacs /etc/init.d/gitlab --スクリプト内でsudoでユーザを変更しているがが-iオプションで起動されると"/"に"\"がついてしまうので、-sオプションに変更--

% update-rc.d gitlab defaults 21

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

% sudo edit /etc/logrotate.d/gitlab --なにか変更が有れば--

設定の確認と起動

インストールガイドの通り、設定を確認して起動

% bundle exec rake gitlab:env:info RAILS_ENV=production

System information

System: Debian 7.2

Current User: git

Using RVM: no

Ruby Version: 1.9.3p194

Gem Version: 1.8.23

Bundler Version:1.3.5

Rake Version: 10.1.0

GitLab information

Version: 6.3.0

Revision: b56f85c

Directory: /var/cache/git/gitlab

DB Adapter: mysql2

URL: http://example.com/gitlab

HTTP Clone URL: http://example.com/gitlab/some-project.git

SSH Clone URL: git@example.com:some-project.git

Using LDAP: no

Using Omniauth: no

GitLab Shell

Version: 1.8.0

Repositories: /home/git/repositories/

Hooks: /home/git/gitlab-shell/hooks/

Git: /usr/bin/git

% /etc/init.d/gitlab restart

Starting both the GitLab Unicorn and Sidekiq...

The GitLab Unicorn web server with pid 974 is running.

The GitLab Sidekiq job dispatcher with pid 985 is running.

GitLab and all its components are up and running.

% bundle exec rake gitlab:check RAILS_ENV=production

Apacheの設定

Portを消費しないRuby Passengerで起動する方法もあるらしいけど、いんすとーるがいどでは単独起動しているので、そのままproxyる。

# add for GitLab

<IfModule mod_proxy.c>

<Proxy http://localhost:8080/gitlab>

Order deny,allow

Allow from all

</Proxy>

ProxyPass /gitlab/ http://localhost:8080/gitlab/

ProxyPassReverse /gitlab/ http://localhost:8080/gitlab/

ProxyPreserveHost On

</IfModule>

ここで、ProxyPreserveHostを知らなくてハマった。

GitLab設定

はじめはadmin@local.hostというユーザで「5iveL!fe」というパスワードで入れるので、さっそく入って、この管理者のパスワードを変える。

あとは、ユーザを登録したり、プロジェクトを作ったりする。

追加の設定

じつは、この他に、

・gitユーザのホームディレクトリーが/home/git/でない

・RAILS_RELATIVE_URL_ROOTは/gitlab

なのでemacsで開いている所とconfig/application.rbでpathの変更を行った。

今後は、「Upgarde information」を参考に、アップグレードしていくつもり。

gitのURLが表示と違う

ううむむ、GitLabの画面ではgit remote add git@example.com:takuya/TestOnGitlab.git なんだけど、十歳はgit@example.com:repositories/takuya/TestOnGitlab.git と repositories/を付けないといけない…

httpの方は、git clone http://example.com/gitlab/takuya/TestOnGitlab.git と表示通りにいけるのだけど

本日のPingbacks(全0件)

Google Web検索 on-o.com内を検索