Redmine(svnよりチェックアウト) + MySQL + Apache + Passanger という構成のRedmine環境を構築するためのメモを残します。
4.文字コードのセット
デフォルト文字列をUTF-8にするため、2箇所の追記を行います。
追記後、「:w」「:q」にて保存を行います。
$ sudo vi /etc/my.cnf --以下、追記箇所-- [mysqld] default-character-set = utf8 --追記箇所ここまで-- --以下は新規作成-- [mysql] default-character-set = utf8 --新規作成ここまで--
5.OSの起動時に、MySQLも起動する
現在の状況を確認後、起動するように修正します。
chkconfig --list mysqld chkconfig mysqld on chkconfig --list mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
7.rootのパスワード一括変更、パスワード無しユーザの削除
必要に応じて、rootのパスワードは別々にセットします。
#=> rootユーザ・匿名ユーザともパスワード無しの状態を確認します mysql> select user,host,password from mysql.user; #=> rootユーザのパスワードあり&匿名ユーザ・パスワード無しの状態を確認します mysql> update mysql.user set password=password('<パスワード>') where user = 'root'; mysql> select user,host,password from mysql.user; #=> rootユーザのパスワードあり&匿名ユーザ無しの状態を確認します mysql> delete from mysql.user where password = ''; mysql> select user,host,password from mysql.user; mysql> flush privileges; mysql> exit;
8.Redmine用のユーザとデータベースを作成
Redmine用のユーザを作成します。
mysql -u root -p Enter password:<パスワード> mysql> grant all privileges on redmine.* to redmine identified by 'redmine'; mysql> select user,host,password from mysql.user; (→ユーザが存在することを確認します) mysql> exit;
Redmine用ユーザでデータベースを作成します。
mysql -u redmine -p Enter password:<パスワード> #=> データベースが存在することを確認します mysql> create database redmine default character set utf8; mysql> show create database redmine; mysql> exit;
9.Rubyのインストール
1.8.7系最新版をダウンロードし、インストールします。
場所はこちら(http://www.ruby-lang.org/ja/)
Rubyの入手と解凍を行います。
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p248.tar.gz tar xzvf ruby-1.8.7-p248.tar.gz
Rubyのコンパイルを行います。 (/usrディレクトリ配下へ配置)
cd ruby-1.8.7-p248 ./configure --prefix=/usr make make test #=>test succeeded make install ruby -v #=>ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-linux]
10.RubyGems のインストール
最新版のURLはこちら(http://rubyforge.org/frs/?group_id=126&release_id=33411)
*tgzをクリックすると現れるURLを使用します。
wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz tar xzvf rubygems-1.3.5.tgz cd rubygems-1.3.5 ruby setup.rb gem -v #=>1.3.5
11.Railsのインストール
gem update --system gem install rails --include-dependencies rails -v #=>Rails 2.3.5
12.RedmineのSubversionリポジトリからのインストール
Redmineのバージョンアップ対応を容易にするために、Redmineのsvnからチェックアウトする形をとります。
インストール先ディレクトリは「/opt/redmine」とします。
mkdir /opt/redmine cd /opt/redmine svn checkout http://redmine.rubyforge.org/svn/branches/0.9-stable/
設定ファイルをコピーし、viで編集します。viの編集方法は上記4.の通りとなります。
cd /opt/redmine/0.9-stable/config cp -p database.yml.example database.yml vi database.yml >> production: adapter: mysql database: redmine host: localhost username: redmine password: redmine encoding: utf8 << || エラー回避のため、gemにてmysqlをインストールしておきます。 >|| gem install mysql
environment.rbファイルを開き、編集を行います。
vi ./environment.rb
編集内容としては、Rails::Initializer.run do |config| 直下に以下を記載します。なお、secretの""内は任意の値でよいです。
config.action_controller.session = { :key => "_myapp_session",:secret => "ab30aaca886ffe24cccb91d54a4956cd"}
環境を作成します。
rake db:migrate RAILS_ENV="production"
初期データをロードします。
rake load_default_data RAILS_ENV="production" #=>言語は「ja」を選択
13.Redmineの仮起動
起動後、CentOS上で設定したIP:3000にアクセスし、起動を確認します。終了はプロンプトで「Ctrl + C」です。
cd /opt/redmine/0.9-stable script/server -e production
14.Passengerのインストール
yum install httpd-devel gcc-c++ apr-devel gem install passenger passenger-install-apache2-module
実行すると以下の2箇所で停止するため、両方ともメモに残しておきます。
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.9/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.9 PassengerRuby /usr/bin/ruby
<VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /somewhere/public # <-- be sure to point to 'public'! <Directory /somewhere/public> AllowOverride all # <-- relax Apache security settings Options -MultiViews # <-- MultiViews must be turned off </Directory> </VirtualHost>
15.Passengerの設定
viにて編集ファイルを開き、先ほどメモした内容を記載します。
cd /etc/httpd/conf.d vi passenger.conf LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11 PassengerRuby /usr/bin/ruby
16.Apacheの設定
Redmineをサブディレクトリで運用するために、設定前にシンボリックリンクを作成しておきます。
ln -s /opt/redmine/0.9-stable/public /var/www/html/redmine
続いて、Passengerの設定を末尾に追加します。
cd /etc/httpd/conf vi httpd.conf
末尾に先ほどメモした内容を修正して追記します。
なお、DocumentRootは他で設定するため、削除します。
また、
一方、サブディレクトリで運用するため、サブディレクトリ名(この場合はredmine)をRailsBaseURIとして設定しておきます。
<VirtualHost *:80> ServerName <IPアドレス or ホスト名> RailsBaseURI /redmine </VirtualHost>
さらに、現在のままだとApacheを起動した際に、
「httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName」
と表示されてしまうため、最終行の「サーバ名:ポート名」を追加しておきます。
# ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If this is not set to valid DNS name for your host, server-generated # redirections will not work. See also the UseCanonicalName directive. # # If your host doesn't have a registered DNS name, enter its IP address here. # You will have to access it by its address anyway, and this will make # redirections work in a sensible way. # #ServerName www.example.com:80 ServerName <サーバ名>:<ポート:デフォルトは80>
17.Redmineのアクセス権変更
cd /opt/redmine/0.9-stable chown -R apache:apache files log tmp config/environment.rb
19.Apacheの自動起動設定
MySQL同様、Apacheも自動起動するようにしておきます。
/sbin/chkconfig httpd on /sbin/chkconfig --list httpd httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
20.ファイアウォールでのhttp許可
デフォルトではhttpは許可されていないため、設定を変更します。
- システム > 管理 > セキュリティレベルとファイアウォールの設定
- 信頼できるサービスに「WWW(HTTP)」を追加
21.再起動
参考
サクッとCentOS 5.3にRedmine + Passenger環境をインストール
http://www.sakuttoly.com/blog/2009/04/redmine_passenger_centos.html