CentOS6.0にredmineをインストールする
CentOS6.0にredmine1.2をインストールしたので、そのメモを残します。
今回はこちらの徒然さめざめサイトをかなり参考にさせて頂ました。
下記は私の作業順通りに記載していますが、後からrubyと紐付けるのがめんどくさいので、下記は先にインストールした方が良いと思います。
# yum install zlib-devel
# yum install openssl-devel
# yum install curl-devel
■MySQLインストール(yumで入っているならそれで問題ないと思います)
# cd /usr/local/src
# wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.58.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
# tar zxfv mysql-5.1.58.tar.gz
# cd mysql-5.1.58
# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=all --with-plugins=max-no-ndb
# make
# make install
■redmineユーザ作っておく
# useradd redmine# mysql
>GRANT ALL PRIVILEGES ON redmine.* TO redmine@"%" IDENTIFIED BY 'redmine' WITH GRANT OPTION;
>GRANT ALL PRIVILEGES ON redmine.* TO redmine@localhost IDENTIFIED BY 'redmine' WITH GRANT OPTION;
>FLUSH PRIVILEGES;
■Rubyのインストール
# cd /usr/local/src
# wget http://core.ring.gr.jp/archives/lang/ruby/1.8/ruby-1.8.7-p352.tar.gz
# tar xvzf ruby-1.8.7-p352.tar.gz
# cd ruby-1.8.7-p352
# ./configure --prefix=/usr
# make
# make install
# インストール状態の確認
# ruby -v
# ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]
■rubygemsのインストール
# cd /usr/local/src
# wget http://rubyforge.org/frs/download.php/74445/rubygems-1.6.2.tgz
# tar xvzf rubygems-1.6.2.tgz
# cd rubygems-1.6.2
# ruby setup.rb
■Railsのインストール
# gem install rails -v=2.3.11
※ここでzlibを入れてなければ、無いよ系のエラーが出るので
# yum install zlib-devel※zlibを関連づけし直して、再度make
# cd /usr/local/src/ruby-1.8.7-p352/ext/zlib
# ruby extconf.rb --with-zlib-include=/usr/include -with-zlib-lib=/usr/lib
# make
# make install
# gem install rails
■rakeのインストール
# gem install rake -v=0.8.7
# gem uninstall rake -v=0.9.2
■その他のgemパッケージのインストール
# gem install mysql
# gem install -v=0.4.2 i18n
■Redmineのインストール
# cd /usr/local/src
# wget http://rubyforge.org/frs/download.php/75097/redmine-1.2.1.tar.gz
# tar xvzf redmine-1.2.1.tar.gz
# mv redmine-1.2.1 redmine
# cd redmine
# mv config/database.yml.example config/database.yml
# vi config/database.yml#変更箇所
username: redmine
password: redmine
developmentのdatabase: redmineに# MySQLのsocketを変更していればそれも変更
socket:/tmp/mysql.sock (MySQLのソケットに合わせる)# mv /usr/local/src/redmine /usr/local
# cd /usr/local/redmine■redmine用データベースの生成と設定
# mysql -u root -e "create database redmine"
# mv config/configuration.yml.example config/configuration.yml
# rake generate_session_store
# RAILS_ENV=production rake db:migrate
# RAILS_ENV=production rake redmine:load_default_data
※ここでopenssl-develを入れてなければ、無いよ系のエラーが出るので
RAILS_ENVで下記エラーが出るので対応
rake aborted!
no such file to load -- openssl# yum install openssl-devel
# cd /usr/local/src/ruby-1.8.6/ext/openssl/
# ruby extconf.rb
# make
# make install
# cd /usr/local/redmine
# gem install mysql
# rake generate_session_store
# RAILS_ENV=production rake db:migrate
# RAILS_ENV=production rake redmine:load_default_data
# yum install ImageMagick-devel
# gem install rmagick
■インストール状態の最終確認
# gem -v
1.6.2
# gem listLOCAL GEMS ***
actionmailer (2.3.11)
actionpack (2.3.11)
activerecord (2.3.11)
activeresource (2.3.11)
activesupport (2.3.11)
i18n (0.4.2)
mysql (2.8.1)
rack (1.1.2)
rails (2.3.11)
rake (0.8.7)
rmagick (2.13.1)■redmineの起動確認
# cd /usr/local/redmineruby script/server
or
ruby script/server webrick -e production
注意: Webrickは通常は開発時に使用すものであり、通常の運用には適していません。
動作確認以外には使用しないでください。本番運用においてはPassenger (mod_rails) や mongrel の利用を検討してください。■ブラウザなどでアクセス
http://localhost:3000/
※ 3000番が空いてなければiptable対応
# vi /etc/sysconfig/iptables# /etc/rc.d/init.d/iptables restart
これでひとまずredmine単体のインストールはOK!!
■apacheとの連携
# gem install passenger# export APXS2=/usr/local/apache2/bin/apxs
# export PATH=/usr/local/apache2/bin:$PATH
# passenger-install-apache2-module※ここでvirtualhost.confの設定が出力されるので、コピーしておく
こんな感じ
- -
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.9
PassengerRuby /usr/bin/rubyAfter you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!Press ENTER to continue.
- -
Deploying a Ruby on Rails application: an example
Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:
ServerName www.yourhost.com
DocumentRoot /somewhere/public # <-- be sure to point to 'public'!
AllowOverride all # <-- relax Apache security settings
Options -MultiViews # <-- MultiViews must be turned off
And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:/usr/lib/ruby/gems/1.8/gems/passenger-3.0.9/doc/Users guide Apache.html
Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
http://www.modrails.com/Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.
httpd.conf設定用
# find / -iname mod_passenger.so
/usr/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/apache2/mod_passenger.so# find / -iname passenger-spawn-server
/usr/lib/ruby/gems/1.8/gems/passenger-3.0.9/helper-scripts/passenger-spawn-server■redmine.confとかの作成
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.9
PassengerRuby /usr/bin/ruby
#
#Header always unset "X-Powered-By"
#Header always unset "X-Rack-Cache"
#Header always unset "X-Content-Digest"
#Header always unset "X-Runtime"#
#PassengerMaxPoolSize 20
#PassengerMaxInstancesPerApp 4
#PassengerPoolIdleTime 3600
#PassengerUseGlobalQueue on
#PassengerHighPerformance on
#PassengerStatThrottleRate 10
#RailsSpawnMethod smart
#RailsAppSpawnerIdleTime 86400
#RailsFrameworkSpawnerIdleTime 0PassengerUserSwitching off
PassengerDefaultUser nobody
#RailsEnv something_that_is_not_production
ServerName xxxx
DocumentRoot /usr/local/redmine/public/
RailsEnv development
RailsBaseURI /ErrorLog "|/usr/local/sbin/cronolog /apache/logs/redmine/error_log.%Y-%m-%d"
Options ExecCGI FollowSymLinks
Options -MultiViewsAllowOverride all
Order allow,deny
#Allow from all
Allow from 192.168.0.0/16
最終的にはVirtualHostの設定を上記のようにしました。
※ちなみにコメントアウトしているオプションはそのうち調べて使おうかと本当はシンボリックリンクを貼ってやりたかったのですが、どうにもうまくいかなくて。。。
その際に
[error] [client 192.168.23.50] Directory index forbidden by Options directive:
こんなエラーとか、あとブラウザで見るとPassengerのエラーが下記のように出ていたりとか
Ruby on Rails application could not be started
●No such file or directory - config/environment.rb
●no such file to load -- /usr/x/redmine/config/environmentそれでPassengerのバージョンとかがやっぱり合わないのかな?とか思い
こんな感じでダウングレードして入れたりとかしたのですが、まあ結局シンボリックリンクが
gem uninstall passenger
gem install passenger -v 2.2.15passenger-install-apache2-module
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /usr/bin/ruby
どうにも私の設定だとダメみたいでした。なので、redmineの実態は/usr/local/redmineにあるので、そこを直接Document Rootと
しちゃいました(正確にはpublicの下ですが)あとredmine自体は
chmod -R 755
chown -R nobody:nobody redmine
してあります。(apacheをnobodyで動かしているので)
結論的には、
access denied とか no such とか no load とか出たらとりあえず直接publicの下を
Document Root設定してしまって試すのが良いと思いました。
じゃないと良くわかんらんエラーでハマります。
あと、Allow from all をお忘れなく(とりあえず試す時は)