さくらVPSのCentOSサーバにGitLab7.1.1を導入した話
この間書いたとおり、GitLabを導入してみたので、その記録を。
基本的には、GitLabの7.1.1のインストールガイドをCentOS 6.5にGitLab 6.8をインストールとSSL導入に従って適宜読み替えて進めただけですね。
CentOS6.5 / Apache2.2 / MySQL5.6 / Git2.0.0 / GitLab7.1.1 / Ruby2.0.0
他のサービスも稼働させるため、サーバーにはApacheを、RedmineがRuby2.1に対応していないのでRubyは2.0.0を利用しています。
まず、libyamlをyumでインストールするため、epelを追加します。
まず、デフォルトで入っているMySQL5.1を削除します。
/etc/my.cnfを開き、[mysqld] セクションに character-set-server=utf8 を書き加え、また[mysql]セクションを追加してそこに default-character-set=utf8 を追加します。
そして、rootユーザーのパスワード変更など必要な初期設定を行います。
まずソースをダウンロード
mysqlにログインして、データベースを作成します。
ユーザー名やデータベース名なんかも特に理由がなければ変更しないが吉ですね。
exampleを取ってきて編集を行います。
特に必要なのは'localhost'というドメインを自分のフルドメインに変えることだけだよ、と説明書にあったのであんまり弄る必要はなさそうです。
設定が完了したら、アクセス権等を調整します。
編集の必要性は多分ないと思います。
基本的にはpasswordを書き換える以外は必要ないと思います。
最後に権限を調整します。
利用する場合はドキュメントに従って編集します。
これであらかた終了です。
あとはApacheとの連携設定です。
次に、Apacheの設定ファイルを開きます。
設定が混入しないよう、独自の設定ファイルを作成します。
疲れました・・・。
本当は、これに加えてメール送信処理まで設定したのですが、それはまたのちほどということで。
基本的には、GitLabの7.1.1のインストールガイドをCentOS 6.5にGitLab 6.8をインストールとSSL導入に従って適宜読み替えて進めただけですね。
0.環境
CentOS6.5 / Apache2.2 / MySQL5.6 / Git2.0.0 / GitLab7.1.1 / Ruby2.0.0
他のサービスも稼働させるため、サーバーにはApacheを、RedmineがRuby2.1に対応していないのでRubyは2.0.0を利用しています。
1.パッケージリポジトリの追加
まず、libyamlをyumでインストールするため、epelを追加します。
yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmまた、GitLab7.1.1はMySQL5.5以降に対応しているため、MySQLの最新バージョンを配布しているパッケージリポジトリを追加しておきます。
yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
1.Gitのインストール
前記事のCentOSにgit-2.0.0を入れる方法に従ってGit2.0.0を入れます。2.MySQL5.6のインストール
まず、デフォルトで入っているMySQL5.1を削除します。
yum remove mysql*そして、導入しなおします。
yum install mysql mysql-devel mysql-server mysql-utilities導入が完了したら、設定をします。
/etc/my.cnfを開き、[mysqld] セクションに character-set-server=utf8 を書き加え、また[mysql]セクションを追加してそこに default-character-set=utf8 を追加します。
[mysqld] ... character-set-server=utf8 ... [mysql] default-character-set=utf8で、サービスを起動し、登録します。
service mysqld start chkconfig mysqld on
そして、rootユーザーのパスワード変更など必要な初期設定を行います。
mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! ... Enter current password for root (enter for none): OK, successfully used password, moving on... ... Change the root password? [Y/n] yes New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! ... Remove anonymous users? [Y/n] yes ... Success! ... Disallow root login remotely? [Y/n] yes ... Success! ... Remove test database and access to it? [Y/n] yes - Dropping test database... ... Success! - Removing privileges on test database... ... Success! ... Reload privilege tables now? [Y/n] yes ... Success! All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! Cleaning up...
3.依存関係の導入
yum install -y gcc gcc-c++ kernel-devel zlib-devel libyaml-devel libffi-devel curl openssl-devel openssh-server redis libxml2-devel libxslt-devel libicu-devel logrotate python-docutils postfix readline-devel gdbm-devel ncurses-develで依存関係のあるパッケージを導入しておきます。
4.Rubyのインストール
今回はRubyは2.0.0を導入します。まずソースをダウンロード
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p451.tar.gz -O ruby-2.0.0.tar.gzで、解凍してビルド
tar zxvf ruby-2.0.0.tar.gz cd ruby-2.0.0 ./configure --disable-install-doc make make installまた、bundlerも利用するのでここでインストールしておきます。
gem install bundler --no-rdoc --no-ri
5.GitLab用ユーザーの作成
GitLabではユーザー名がgitになるよう作られているので、必要がなければこれに従います。useradd -c 'GitLab' -s /bin/bash gitgitにログインしてauthorized_keysを作成します。
su - git mkdir .ssh touch .ssh/authorized_keys chmod 600 .ssh/authorized_keys chmod 700 .ssh
6.データベースを用意します。
MySQLの設定方法は別ファイルになっていて、こちらですね。mysqlにログインして、データベースを作成します。
ユーザー名やデータベース名なんかも特に理由がなければ変更しないが吉ですね。
create user 'git'@'localhost' identified by '$password'; set storage_engine=INNODB; create database if not exists 'gitlabhq_production' default character set 'utf8' collate 'utf8_unicode_ci'; grant select, look tables, insert, delete, create, drop, index, alter on 'gitlabhq_production'.* to 'git'@'localhost';$passwordには適宜パスワードを入れてください。
7.GitLabをインストール
ついに本体を入れます。su - git git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-1-stable gitlab cd gitlabでは、設定です。
exampleを取ってきて編集を行います。
cp config/gitlab.yml.example config/gitlab.yml vim config/gitlab.yml設定ファイルは適宜変更してください。
特に必要なのは'localhost'というドメインを自分のフルドメインに変えることだけだよ、と説明書にあったのであんまり弄る必要はなさそうです。
設定が完了したら、アクセス権等を調整します。
su - root Password: cd /home/git/gitlab chown -R git log/ chown -R git tmp/ chown -R u+rwX log/ chown -R u+rwX tmp/ chmod -R u+rwX tmp/pids/ chmod -R u+rwX tmp/sockets/ chmod -R u+rwX public/uploadssatellites用フォルダを作成します。
su - git mkdir /home/git/gitlab-satellites exit chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellitesアカウントをgitに戻し、その他の設定ファイルを作成します。
編集の必要性は多分ないと思います。
exit cp config/unicorn.rb.example config/unicorn.rb cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb最後にgitのユーザー設定をします。
git config --global user.name "GitLab" git config --global user.email "example@example.com" git config --global core.autocrlf input
8.データベース設定を編集します。
cp config/database.yml.mysql config/database.yml vim config/database.yml適宜書き換えてください。
基本的にはpasswordを書き換える以外は必要ないと思います。
最後に権限を調整します。
chmod o-rwx config/database.yml
9.Gemから色々入れます
bundle install --deployment --without development test postgres aws
10.Redisを導入します
yum install redis service redis start chkconfig redis on
11.GitLab Shellを導入します
bundle exec rake gitlab:shell:install[v1.9.6] REDIS_URL=redis://localhost:6379 RAILS_ENV=productionGitLab Shellは/home/git/gitlab-shellにインストールされます。configファイルは/home/git/gitlab-shell/config.ymlですが、httpsを利用しないのであれば編集する必要はあまりありません。
利用する場合はドキュメントに従って編集します。
12.データベースを初期化します。
bundle exec rake gitlab:setup RAILS_ENV=production
13.Init Scriptを導入します。
su - root cp lib/support/init.d/gitlab /etc/init.d/gitlab
14.logrotateを導入します
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
15.プログラムの状況を確認します。
ユーザーをgitに戻して状況を確認します。bundle exec rake gitlab:env:info RAILS_ENV=production
16.コンパイルします。
bundle exec rake assets:precompile RAILS_ENV=production
17.GitLabを起動して自動起動に登録します
su - root service gitlab start chkconfig gitlab on
これであらかた終了です。
あとはApacheとの連携設定です。
18.Passengerの導入
gem install passenger --no-rdoc --no-ri passenger-install-apache2-module passenger-install-apache2-module --snippetを実行し、表示された設定を控えます。
次に、Apacheの設定ファイルを開きます。
設定が混入しないよう、独自の設定ファイルを作成します。
vim /etc/httpd/conf.d/passenger.confここに、先ほど控えた設定を貼り付けて保存します。
19.VirtualHostの設定
vim /etc/httpd/conf.d/gitlab.confで設定ファイルを開き、以下のとおり記述します。
<VirtualHost> ServerName your.server.name DocumentRoot /home/git/gitlab/public ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ </VirtualHost>
20.Apacheの起動
service httpd configtest service httpd start chkconfig httpd on以上で、GitLabの導入完了です。
疲れました・・・。
本当は、これに加えてメール送信処理まで設定したのですが、それはまたのちほどということで。
コメント
0 件のコメント :
コメントを投稿