月別アーカイブ 2017年9月11日

Redmine3.3のインストール(CentOS7.3)

Red Hat Software Collections (RHSCL)

Ruby 2.3 をパッケージでインストールするために RHSCL 2.3 相当の centos-sclo-rh リポジトリを追加

# yum install -y centos-release-scl-rh
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* centosplus: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Resolving Dependencies
–> Running transaction check
—> Package centos-release-scl-rh.noarch 0:2-2.el7.centos will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
centos-release-scl-rh noarch 2-2.el7.centos extras 12 k

Transaction Summary
================================================================================
Install 1 Package

Total download size: 12 k
Installed size: 19 k
Downloading packages:
centos-release-scl-rh-2-2.el7.centos.noarch.rpm | 12 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : centos-release-scl-rh-2-2.el7.centos.noarch 1/1
Verifying : centos-release-scl-rh-2-2.el7.centos.noarch 1/1

Installed:
centos-release-scl-rh.noarch 0:2-2.el7.centos

Complete!

Ruby2.3をインストール

# yum -y install rh-ruby23 && source scl_source enable $_
echo -e ‘#!/bin/bash\nsource scl_source enable rh-ruby23’ > /etc/profile.d/rh-ruby23.sh

Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : scl-utils-20130529-17.el7_1.x86_64 1/13
Installing : rh-ruby23-runtime-2.2-7.el7.x86_64 2/13
Installing : rh-ruby23-ruby-libs-2.3.1-64.el7.x86_64 3/13
Installing : rh-ruby23-rubygem-io-console-0.4.5-64.el7.x86_64 4/13
Installing : rh-ruby23-rubygem-did_you_mean-1.0.0-64.el7.x86_64 5/13
Installing : rh-ruby23-rubygem-psych-2.0.17-64.el7.x86_64 6/13
Installing : rh-ruby23-ruby-irb-2.3.1-64.el7.noarch 7/13
Installing : rh-ruby23-ruby-2.3.1-64.el7.x86_64 8/13
Installing : rh-ruby23-rubygem-bigdecimal-1.2.8-64.el7.x86_64 9/13
Installing : rh-ruby23-rubygems-2.5.1-64.el7.noarch 10/13
Installing : rh-ruby23-rubygem-json-1.8.3-64.el7.x86_64 11/13
Installing : rh-ruby23-rubygem-rdoc-4.2.1-64.el7.noarch 12/13
Installing : rh-ruby23-2.2-7.el7.x86_64 13/13
Verifying : rh-ruby23-rubygem-json-1.8.3-64.el7.x86_64 1/13
Verifying : rh-ruby23-rubygem-io-console-0.4.5-64.el7.x86_64 2/13
Verifying : rh-ruby23-ruby-2.3.1-64.el7.x86_64 3/13
Verifying : rh-ruby23-rubygem-rdoc-4.2.1-64.el7.noarch 4/13
Verifying : rh-ruby23-rubygem-did_you_mean-1.0.0-64.el7.x86_64 5/13
Verifying : rh-ruby23-2.2-7.el7.x86_64 6/13
Verifying : rh-ruby23-ruby-irb-2.3.1-64.el7.noarch 7/13
Verifying : rh-ruby23-rubygem-psych-2.0.17-64.el7.x86_64 8/13
Verifying : rh-ruby23-ruby-libs-2.3.1-64.el7.x86_64 9/13
Verifying : rh-ruby23-rubygem-bigdecimal-1.2.8-64.el7.x86_64 10/13
Verifying : rh-ruby23-runtime-2.2-7.el7.x86_64 11/13
Verifying : rh-ruby23-rubygems-2.5.1-64.el7.noarch 12/13
Verifying : scl-utils-20130529-17.el7_1.x86_64 13/13

Installed:
rh-ruby23.x86_64 0:2.2-7.el7

Dependency Installed:
rh-ruby23-ruby.x86_64 0:2.3.1-64.el7
rh-ruby23-ruby-irb.noarch 0:2.3.1-64.el7
rh-ruby23-ruby-libs.x86_64 0:2.3.1-64.el7
rh-ruby23-rubygem-bigdecimal.x86_64 0:1.2.8-64.el7
rh-ruby23-rubygem-did_you_mean.x86_64 0:1.0.0-64.el7
rh-ruby23-rubygem-io-console.x86_64 0:0.4.5-64.el7
rh-ruby23-rubygem-json.x86_64 0:1.8.3-64.el7
rh-ruby23-rubygem-psych.x86_64 0:2.0.17-64.el7
rh-ruby23-rubygem-rdoc.noarch 0:4.2.1-64.el7
rh-ruby23-rubygems.noarch 0:2.5.1-64.el7
rh-ruby23-runtime.x86_64 0:2.2-7.el7
scl-utils.x86_64 0:20130529-17.el7_1

Complete!

Phusion Passenger のインストール

ln -s /opt/rh/rh-ruby23/root/usr/lib64/libruby.so.2.3 /usr/lib64/
yum -y install rh-passenger40 rh-passenger40-mod_passenger && source scl_source enable rh-passenger40
echo -e ‘#!/bin/bash\nsource scl_source enable rh-passenger40’ > /etc/profile.d/rh-passenger40.sh

rh-passenger40 は rh-ruby22 までしか対応していないが、rh-ruby22 だと bundle exec rake generate_secret_token を実行した際に何故か Could not find rake in any of the sources というエラーでこけるため、rh-ruby23 / rh-passenger40 の組合せ。

Git

yum -y install rh-git29 && source scl_source enable $_
echo -e ‘#!/bin/bash\nsource scl_source enable rh-git29’ > /etc/profile.d/rh-git29.sh

base リポジトリだと 1.8.3 がインストールされるため RHSCL の rh-git29 コレクションを利用する。

必要ライブラリのインストール

# yum install -y rh-ruby23-{ruby-devel,rubygem-bundler}
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* centosplus: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Resolving Dependencies
–> Running transaction check
—> Package rh-ruby23-ruby-devel.x86_64 0:2.3.1-64.el7 will be installed
—> Package rh-ruby23-rubygem-bundler.noarch 0:1.10.6-4.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================
Package Arch Version Repository Size
==================================================================================================
Installing:
rh-ruby23-ruby-devel x86_64 2.3.1-64.el7 centos-sclo-rh 110 k
rh-ruby23-rubygem-bundler noarch 1.10.6-4.el7 centos-sclo-rh 229 k

Transaction Summary
==================================================================================================
Install 2 Packages

Total download size: 338 k
Installed size: 964 k
Downloading packages:
(1/2): rh-ruby23-ruby-devel-2.3.1-64.el7.x86_64.rpm | 110 kB 00:00:01
(2/2): rh-ruby23-rubygem-bundler-1.10.6-4.el7.noarch.rpm | 229 kB 00:00:01
————————————————————————————————–
Total 182 kB/s | 338 kB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : rh-ruby23-rubygem-bundler-1.10.6-4.el7.noarch 1/2
Installing : rh-ruby23-ruby-devel-2.3.1-64.el7.x86_64 2/2
Verifying : rh-ruby23-ruby-devel-2.3.1-64.el7.x86_64 1/2
Verifying : rh-ruby23-rubygem-bundler-1.10.6-4.el7.noarch 2/2

Installed:
rh-ruby23-ruby-devel.x86_64 0:2.3.1-64.el7 rh-ruby23-rubygem-bundler.noarch 0:1.10.6-4.el7

Complete!

# yum install -y gcc {mysql-community,libxml2,libxslt,ImageMagick}-devel ipa-pgothic-fonts
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* centosplus: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Package gcc-4.8.5-11.el7.x86_64 already installed and latest version
No package mysql-community-devel available.
Package libxml2-devel-2.9.1-6.el7_2.3.x86_64 already installed and latest version
Package ImageMagick-devel-6.7.8.9-15.el7_2.x86_64 already installed and latest version
Resolving Dependencies
–> Running transaction check
—> Package ipa-pgothic-fonts.noarch 0:003.03-5.el7 will be installed
—> Package libxslt-devel.x86_64 0:1.1.28-5.el7 will be installed
–> Processing Dependency: libgcrypt-devel for package: libxslt-devel-1.1.28-5.el7.x86_64
–> Running transaction check
—> Package libgcrypt-devel.x86_64 0:1.5.3-13.el7_3.1 will be installed
–> Processing Dependency: libgpg-error-devel for package: libgcrypt-devel-1.5.3-13.el7_3.1.x86_64
–> Running transaction check
—> Package libgpg-error-devel.x86_64 0:1.12-3.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================
Package Arch Version Repository Size
==================================================================================================
Installing:
ipa-pgothic-fonts noarch 003.03-5.el7 base 3.5 M
libxslt-devel x86_64 1.1.28-5.el7 base 309 k
Installing for dependencies:
libgcrypt-devel x86_64 1.5.3-13.el7_3.1 updates 129 k
libgpg-error-devel x86_64 1.12-3.el7 base 16 k

Transaction Summary
==================================================================================================
Install 2 Packages (+2 Dependent packages)

Total download size: 4.0 M
Installed size: 8.6 M
Downloading packages:
(1/4): libgcrypt-devel-1.5.3-13.el7_3.1.x86_64.rpm | 129 kB 00:00:00
(2/4): libgpg-error-devel-1.12-3.el7.x86_64.rpm | 16 kB 00:00:00
(3/4): ipa-pgothic-fonts-003.03-5.el7.noarch.rpm | 3.5 MB 00:00:00
(4/4): libxslt-devel-1.1.28-5.el7.x86_64.rpm | 309 kB 00:00:00
————————————————————————————————–
Total 6.1 MB/s | 4.0 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libgpg-error-devel-1.12-3.el7.x86_64 1/4
Installing : libgcrypt-devel-1.5.3-13.el7_3.1.x86_64 2/4
Installing : libxslt-devel-1.1.28-5.el7.x86_64 3/4
Installing : ipa-pgothic-fonts-003.03-5.el7.noarch 4/4
Verifying : ipa-pgothic-fonts-003.03-5.el7.noarch 1/4
Verifying : libgpg-error-devel-1.12-3.el7.x86_64 2/4
Verifying : libxslt-devel-1.1.28-5.el7.x86_64 3/4
Verifying : libgcrypt-devel-1.5.3-13.el7_3.1.x86_64 4/4

Installed:
ipa-pgothic-fonts.noarch 0:003.03-5.el7 libxslt-devel.x86_64 0:1.1.28-5.el7

Dependency Installed:
libgcrypt-devel.x86_64 0:1.5.3-13.el7_3.1 libgpg-error-devel.x86_64 0:1.12-3.el7

Complete!

Redmine のインストール

cd /var/www && git clone https://github.com/redmine/redmine.git && cd redmine
git checkout `git tag | tail -n 1`
bundle config build.nokogiri –local –use-system-libraries
cat << "_EOF_" > config/database.yml
production:
adapter: mysql2
database: redmine
host: localhost
username: root
password: P@ssw0rd
encoding: utf8
_EOF_
bundle install –without development test
bundle exec rake generate_secret_token
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake redmine:load_default_data RAILS_ENV=production REDMINE_LANG=ja
chown -R apache. /var/www/redmine
chmod -R 755 files log tmp public/plugin_assets
setenforce 0 #TODO: SELinux Settings

そのままだと nokogiri のインストール時に An error occurred while installing nokogiri, and Bundler cannot continue. とエラーが出るので、–use-system-libraries オプションを事前に指定してやる。

rh-ror42-rubygem-bundler 以外にも rubygem パッケージがあるが、バージョンが足りないものやパッケージ化されていないものもあり、また検証した結果不具合が生じるのでパッケージ利用を断念。

bundle exec rails server webrick -e production -b 192.168.56.101 を実行すると簡易的に http://192.168.56.101:3000/ でアクセスできるようになるので、切り分けが必要なときなどに利用する。

ruby-2.4.1をソースからビルド(RHEL4)

zlibが入ってない場合は、zlibのサイト
https://zlib.net/
から、zlibをダウンロードする。

# tar -zxvf zlib-1.2.11.tar.gz
# cd zlib-1.2.11
# ./configure
# make
# make install

rubyのダウンロードサイト
https://www.ruby-lang.org/ja/downloads/
から、rubyをダウンロードする。

解凍
# tar -zxvf ruby-2.4.1.tar.gz

コンパイル
# cd ruby-2.4.1
#./configure –prefix=/usr/local/ruby
# make

インストール
# sudo make install

rubyのパスを通す
$ export PATH=/usr/local/ruby/bin:$PATH
$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [i686-linux]

rubygemsをインストールします。

rubygemsのサイト
https://rubygems.org/
から、ソースをダウンロード
# tar -zxvf rubygems-2.6.13.tgz

# cd rubygems-2.6.13
# ruby setup.rb
——————————————————————————

RubyGems installed the following executables:
/usr/local/ruby/bin/gem

Ruby Interactive (ri) documentation was installed. ri is kind of like man
pages for ruby libraries. You may access it like this:
ri Classname
ri Classname.class_method
ri Classname#instance_method
If you do not wish to install this documentation in the future, use the
–no-document flag, or set it as the default in your ~/.gemrc file. See
‘gem help env’ for details.

続いて、rakeのインストール

# gem install rake
ERROR: While executing gem … (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

エラー発生。

# cd /usr/local/src/ruby-2.4.1/ext/openssl

Makefileのtopdirの下に下記1行を追加する。
top_srcdir = /usr/local/src/ruby-2.4.1

# ruby extconf.rb
checking for t_open() in -lnsl… no
checking for socket() in -lsocket… no
checking for openssl/ssl.h… yes
checking for OpenSSL version is 0.9.8 or later… no
extconf.rb:60:in `

‘: OpenSSL 0.9.8 or later required. (RuntimeError)

バージョンを確認すると、
# openssl version
OpenSSL 0.9.7a Feb 19 2003

opensslのサイト
https://www.openssl.org/source/
から、ソースをダウンロードする。

解凍
# tar -zxvf openssl-1.0.2l.tar.gz

コンパイル
# cd openssl-1.0.2l
# ./config -fPIC shared
# make

インストール
# make install

openssl-1.0.2lをライブラリパスに追加する。
/etc/ld.so.confにライブラリを追加する。

/usr/local/ssl/lib ←追加
include ld.so.conf.d/*.conf

設定反映
# ldconfig

反映確認
# ldconfig -p | grep ssl
libssl3.so (libc6) => /usr/lib/libssl3.so
libssl.so.4 (libc6) => /lib/libssl.so.4
libssl.so.1.0.0 (libc6) => /usr/local/ssl/lib/libssl.so.1.0.0
libssl.so (libc6) => /usr/local/ssl/lib/libssl.so
libssl.so (libc6) => /usr/lib/libssl.so
libcrypto.so.1.0.0 (libc6) => /usr/local/ssl/lib/libcrypto.so.1.0.0
libcrypto.so (libc6) => /usr/local/ssl/lib/libcrypto.so

バージョン確認
# /usr/local/ssl/bin/openssl version
OpenSSL 1.0.2l 25 May 2017

パスを通す
# export PATH=/usr/local/ssl/bin:$PATH

rubyをリコンパイル&インストール
# cd /usr/local/src/ruby-2.4.1
# ./configure –prefix=/usr/local/ruby –with-opt-dir=/usr/local/ssl –enable-shared
# make
# make install

改めて、rakeをインストール
# gem install rake
Successfully installed rake-12.0.0
Parsing documentation for rake-12.0.0
Installing ri documentation for rake-12.0.0
Done installing documentation for rake after 1 seconds
1 gem installed

# gem install reils
・・・
Parsing documentation for sprockets-rails-3.2.1
Installing ri documentation for sprockets-rails-3.2.1
Parsing documentation for rails-5.1.4
Installing ri documentation for rails-5.1.4
Done installing documentation for i18n, thread_safe, tzinfo, concurrent-ruby, activesupport, rack, rack-test, mini_portile2, nokogiri, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, arel, activerecord, globalid, activejob, mime-types-data, mime-types, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, thor, method_source, railties, bundler, sprockets, sprockets-rails, rails after 205 seconds
36 gems installed

$ cd redmine
$ rake config/

Could not find gem ‘rails (= 4.2.8)’ in any of the gem sources listed in your Gemfile.

# bundle install
・・・
Bundler::SudoNotPermittedError: Bundler requires sudo access to install at the
moment. Try installing again, granting Bundler sudo access when prompted, or
installing into a different path.
An error occurred while installing i18n (0.7.0), and Bundler cannot
continue.
Make sure that `gem install i18n -v ‘0.7.0’` succeeds before bundling.

In Gemfile:
rails was resolved to 4.2.8, which depends on
actionmailer was resolved to 4.2.8, which depends on
actionpack was resolved to 4.2.8, which depends on
actionview was resolved to 4.2.8, which depends on
rails-dom-testing was resolved to 1.0.8, which depends on
rails-deprecated_sanitizer was resolved to 1.0.3, which depends on
activesupport was resolved to 4.2.8, which depends on
i18n