Infra DevOps

インフラ構築のナレッジや、運用の自動簡易化に関する記事を書いていこうと思います

Redmineの構築手順

ここ最近で一番ハマったかも。

Redmineのインストール、設定が厄介だったのでメモ

なお、Apacheはインストール済み前提です。この手順では2.4を利用してました。 

 

 

1 コンパイルに必要なパッケージ追加

1-1 rubyに必要なパッケージ追加
# rpm -qa | grep devel | sort -f ; rpm -qa | grep libx
# yum install zlib-devel libcurl-devel openssl-devel readline-devel libyaml-devel libxml2 libxslt libxml2-devel libxslt-devel


2 redmine用画像、フォントパッケージ追加

2-1 redmine用画像、フォントパッケージ追加
# rpm -qa | grep ImageMagick
# rpm -qa | grep ipa
# yum install ImageMagick ImageMagick-devel ipa-pgothic-fonts


3 MySQLインストール

3-1 MySQLインストール
# rpm -qa | grep mysql
# yum install mysql-server mysql-devel


4 rubyインストール

4-1 ソースダウンロード
# cd /usr/local/src
# curl -O https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz


4-2 ソースコンパイル、インストール
# tar zxvf ruby-2.2.2.tar.gz
# cd ruby-2.2.2
# ./configure --prefix=/usr/local/ruby --disable-install-doc
# make
# cd /usr/local/src/ruby-2.2.2
# make install


4-3 bundlerのインストール
# export PATH=${PATH}:/usr/local/ruby/bin
# gem install bundler --no-rdoc --no-ri
# gem list bundler

5 mysqlデータベース設定

5-1 mysql設定ファイル修正
# vi /etc/my.cnf
~~~
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

character-set-server=utf8

innodb_file_per_table
query-cache-size=16M

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[mysql]
default-character-set=utf8



5-2 mysql_secure_installation実行
# service mysqld start
# mysql_secure_installation
~~~
Enter current password for root (enter for none): (そのままEnter)
~~~
Set root password? [Y/n] Y
New password:
Re-enter new password:
~~~
Remove anonymous users? [Y/n] Y
~~~
Disallow root login remotely? [Y/n] Y
~~~
Remove test database and access to it? [Y/n] Y
~~~
Reload privilege tables now? [Y/n] Y

 

5-3 redmine用データベース、ユーザ作成
# mysql -uroot -p
mysql> create database redmine default character set utf8;
mysql> grant all on redmine.* to redmine@localhost identified by 'PASSWD';
mysql> flush privileges;
mysql> exit;


6 redmineインストール

6-1 パッケージインストール
# cd /usr/local/src
# curl -O http://www.redmine.org/releases/redmine-3.2.2.tar.gz
# tar zxvf redmine-3.2.2.tar.gz
# mv redmine-3.2.2 /var/redmine


6-2 redmineに必要なGEMインストール
# cd /var/redmine
# export PATH=${PATH}:/usr/local/ruby/bin
# bundle install --without development test


6-3 redmineSMTPサーバ設定
# cd /var/redmine/config
# cp -p configuration.yml.example configuration.yml
# vi configuration.yml
~~~
delivery_method: :smtp
smtp_settings:
address: "SMTP.No.FQDN.dayo"
port: 25

6-4 redmineからMySQLへの接続用設定
# cd /var/redmine/config
# cp -p database.yml.example database.yml
# vi database.yml
~~~
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "PASSWD"
encoding: utf8

#development:
# adapter: mysql2
# database: redmine_development
# host: localhost
# username: root
# password: ""
# encoding: utf8


#test:
# adapter: mysql2
# database: redmine_test
# host: localhost
# username: root
# password: ""
# encoding: utf8


6-5 redmine用にsqlを設定
# gem install mysql2
# bundle install --without development test
# bundle exec rake generate_secret_token
# RAILS_ENV=production bundle exec rake db:migrate


7 Passengerインストール

7-1 Passengerインストール準備
# gem install passenger --no-rdoc --no-ri
# export APXS2=/usr/local/apache2/bin/apxs
# export PATH=${PATH}:/usr/local/apache2/bin

 

7-2 Passengerインストール
# passenger-install-apache2-module
~~~~~
Please edit your Apache configuration file, and add these lines:

LoadModule passenger_module /usr/local/ruby/lib/ruby/gems/2.2.0/gems/passenger-5.0.28/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/ruby/lib/ruby/gems/2.2.0/gems/passenger-5.0.28
PassengerDefaultRuby /usr/local/ruby/bin/ruby
</IfModule>

After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration
※このままの状態にしておき、別のTeraTermウインドウを1つ追加で立ち上げる

7-3 別のウインドウを起動し、passenger-install-apache2-moduleのコマンド結果に表示された
httpd.confに追記すべき定義を新規redmine.confファイルに記載する
# vi /etc/httpd/conf/extra/redmine.conf
~~~
LoadModule passenger_module /usr/local/ruby/lib/ruby/gems/2.2.0/gems/passenger-5.0.28/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/ruby/lib/ruby/gems/2.2.0/gems/passenger-5.0.28
PassengerDefaultRuby /usr/local/ruby/bin/ruby
</IfModule>

Alias /redmine /var/redmine/public

<Location /redmine>
PassengerEnabled on
RailsEnv production
PassengerBaseURI /redmine
PassengerAppRoot /var/redmine
</Location>

<Directory "/var/redmine/public">
AllowOverride All
Options -MultiViews
Require all granted
</Directory>
7-4 httpd.confにredmine用設定ファイルインクルードの設定を追加
# vi /etc/httpd/conf/extra/httpd-vhosts.conf
~~~
# Configure Genesis Redmine settings
Include /etc/httpd/conf/extra/redmine.conf

# Secure (SSL/TLS) connections


7-5 redmineディレクトリフォルダ権限の変更
# chown -R apache:apache /var/redmine


7-6 httpd再起動
# service httpd restart


7-7 7-2のウインドウに戻ってEnterキーを押下する
Press ENTER when you are done editing.


--------------------------------------------

Validating installation...

* Checking whether this Passenger install is in PATH... ?
* Checking whether there are no other Passenger installations... ?
* Checking whether Apache is installed... ?
* Checking whether the Passenger module is correctly configured in Apache... ?

Everything looks good. :-)


7-8 ブラウザから「http://サーバIP/redmine」にアクセスし、redmineのホーム画面が表示されることを確認する

 で社内ADユーザLDAPアカウント使った認証させたのだが

f:id:liaisondangereuse:20160826174519p:plain

 て設定すれば良さそうだった