Redmine構築
Redmine構築手順
プロジェクト管理ツールであるRedmineを構築した時の手順
参考ページは以下
http://blog.redmine.jp/articles/2_5/installation_centos/
環境
OS:CentOS6.5
Remine:2.6.6 http://www.redmine.org/projects/redmine/wiki/Download
Apache:2.2.5
MySQL:5.6 http://weblabo.oscasierra.net/installing-mysql-rhel6-with-yum/ (参考)
Ruby:2.0.0 https://www.ruby-lang.org/ja/news/2015/02/25/ruby-2-0-0-p643-is-released/
1.SELinuxを無効にする
/etc/selinux/config の設定を変更
SELINUX=Disabled
設定後に再起動
2.iptables を無効にする
chkconfig iptables off
設定変更後の確認
chkconfig --list | grep iptables
3.EPELリポジトリのインストール
wget epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
インストール後の確認
yum repolist
epel が表示されていればOK
4.必要なパッケージのインストール
開発ツール
yum groupinstall "Development Tools"
RubyとPassengerのビルドに必要なフインストール
yum install openssl-devel readline-devel zlib-devel curl-devel libyaml-devel
MySQL5.6
yum -y install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
※足りない場合
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-devel-5.6.20-1.el6.x86_64.rpm \
rpm -ivh MySQL-5.6/MySQL-devel-5.6.20-1.el6.x86_64.rpm
yum -y install ImageMagick ImageMagick-devel ipa-pgothic-fonts
Rubyのインストール
wget https://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p643.tar.gz
tar zxvf ruby-2.0.0-p643.tar.gz
cd ruby-2.0.0-p643
./configure --disable-install-doc
make
make install
cd ..
インストールの確認
ruby -v
bundlerのインストール
Gemの一括インストール用のコマンド
gem install bundler --no-rdoc --no-ri
MySQLの設定
/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
設定の反映のために再起動&起動設定
service mysqld restart
chkconfig mysqld restart
設定反映の確認
mysql -uroot
mysql> show variables like 'character_set%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
mysql> exit
MySQLの初期設定ツールを使用
rootユーザのパスの変更
匿名ユーザ、不要なユーザデータベースの削除
mysql_secure_installation
:
(中略)
:
Enter current password for root (enter for none): (そのままEnterキーを押す)
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y
New password: (MySQLのrootユーザーに新たに設定するパスワードを入力)
Re-enter new password: (新パスワードを再入力)
Password updated successfully!
Reloading privilege tables..
... Success!
:
(中略)
:
Remove anonymous users? [Y/n] y (匿名ユーザーを削除)
... Success!
:
(中略)
:
Disallow root login remotely? [Y/n] y (rootユーザーの接続元をlocalhostに限定)
... Success!
:
(中略)
:
Remove test database and access to it? [Y/n] y (testデータベースを削除)
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
:
(中略)
:
Reload privilege tables now? [Y/n] y (これまでの変更を直ちに適用)
... Success!
Redmine用のデータベースの作成
mysql -uroot -p
mysql> create database db_redmine default character set utf8;
mysql> grant all on db_redmine.* to user_redmine@localhost identified by '任意のパス';
mysql> flush privileges;
mysql> exit;
Redmineのダウンロード
tar xvf redmine-2.6.6.tar.gz
mv redmine-2.6.6 /var/lib/redmine
データベースへの接続設定
vi config/configuration.yml
production:
adapter: mysql2
database: db_redmine
host: localhost
username: user_redmine
password: (mysqlの設定で使用した任意のパス)
encoding: utf8
設定ファイルの作成
vi cinfig/configuration.yml
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "localhost"
port: 25
domain: 'example.com'
rmagick_font_path: /usr/share/fonts/ipa-pgothic/ipagp.ttf
Gemパッケージのインストール
bundle install --without development test
Remineの初期設定とデータベースの初期化
bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
Passengerのインストール
gem install passenger --no-rdoc --no-ri
Apacheモジュールのインストール
passenger-install-apache2-module
※足りないパッケージがあれば、インストールが止まる
→不足分をインストール
最後に出てくる白太字の文字をとっておく
→Apacheとの連携で使用
passenger-install-apache2-module --snippetで参照可能
Apacheの設定
Passengerの設定追加
/etc/httpd/conf.d/passenger.conf を作成
# Passengerの基本設定。
# passenger-install-apache2-module --snippet を実行して表示される設定を使用。
# 環境によって設定値が異なりますので以下の3行はそのまま転記しないでください。
#
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.17
PassengerRuby /usr/local/bin/ruby
# Passengerが追加するHTTPヘッダを削除するための設定(任意)。
#
Header always unset "X-Powered-By"
Header always unset "X-Rack-Cache"
Header always unset "X-Content-Digest"
Header always unset "X-Runtime"
# 必要に応じてPassengerのチューニングのための設定を追加(任意)。
# 詳しくはPhusion Passenger users guide(http://www.modrails.com/documentation/Users%20guide%20Apache.html)をご覧ください。
PassengerMaxPoolSize 20
PassengerMaxInstancesPerApp 4
PassengerPoolIdleTime 3600
PassengerHighPerformance on
PassengerStatThrottleRate 10
PassengerSpawnMethod smart
RailsAppSpawnerIdleTime 86400
PassengerMaxPreloaderIdleTime 0
※軌道が遅い場合は、PassengerStartTimeoutの記述を追加
Apacheの再起動&起動設定
service httpd restart
chkconfig httpd on
Redmineの使用設定
chown -R apache:apache /var/lib/redmine
DocumentRootの変更
DocumentRoot "/var/lib/redmine/public"
Apache再起動
/etc/init.d/httpd configtest
/etc/init.d/httpd graceful