Debianでredmineを動かせなかった

aptitude install redmineでインストールされるredmineのバージョンが非常に低かったので、最新版のredmineをなんとかインストールしようと頑張ったけどできなかった。

これは、できなかった、という記事です。ごめんなさい。

とりあえず、RDBMSのインストール
#aptitude install postgresql
#aptitude install mysql-client mysql-server
#aptitude install libapache2-mod-php5
RVMのインストール

redmine2.2.0は、ruby1.9.3とのことで、RubyのバージョンマネージャRVMを使ってバージョンを管理してやろうと思った。

公式:RVM: Ruby Version Manager - Installing RVM

#\curl -L https://get.rvm.io | bash -s stable --ruby
  * To start using RVM you need to run `source /usr/local/rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

足りないものをインストール。

#aptitude install bison

.bashrcに以下のコマンドを追加

source /usr/local/rvm/scripts/rvm
Rubyのインストール

Rubyのインストール。

#rvm install ruby-1.9.3-head

よくわかっていないが、とりあえずいっぱいインストール。

#gem install rubygems-update
#gem install rspec
#gem install rspec-rails
#gem install git
#gem install pkg-config
#gem update

RVMを使ったredmineのインストール

参考:rvmを利用してredmineインストール(EC2)メモ - developer's diary

redmineのgemsetを作って利用
#rvm gemset create redmine
#rvm gemset use redmine
railsのインストール

redmine 2.2.0のrailsは3.2.10とのこと。ということでrails3.2.10をインストールする。

公式:RedmineInstall - Redmine

#gem install rails -v=3.2.10
#gem install railties -v=3.2.10

gem install mysql
gem clearnup


以下から一般ユーザで処理してみる。

ダウンロードサイトからwgetでダ
ウンロードする。

$wget http://rubyforge.org/frs/download.php/76627/redmine-2.2.0.tar.gz
$tar zxvf redmine-2.2.0.tar.gz
$cd redmine-2.2.0
$cp config/database.yml.example config/database.yml
$vi config/database.yml
production:
  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: "redminepass"
  encoding: utf8
#rails
Could not find builder (~> 3.0.0)

gem listで確認すると、builder(3.1.0)になっており、バージョンが合わないらしい。

参考:久しぶりに Rails 触ったらエラーでコケた - @sugamasao.blog.title # => ”コードで世界を変えたい”

#gem install builder --version '~> 3.0.0'
#rails
Could not find sprockets (~> 2.2.1)
#gem install sprockets --version '~> 2.2.1'

#bundle installを実行するも、いろいろインストール出来ないものが現れて、その度にaptitudeでインストールした。

#rake generate_session_store
#update_rubygems
#bundle install
An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.
#aptitude install libmysqlclient15-dev
#bundle install
An error occurred while installing pg (0.14.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.14.1'` succeeds before bundling.
#aptitude install libapq-postgresql1-dev
#bundle install
An error occurred while installing rmagick (2.13.1), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.1'` succeeds before bundling.
#aptitude install libmagick9-dev
#bundle install
An error occurred while installing sqlite3 (1.3.6), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling.
#aptitude install sqlite3
#aptitude install libsqlite3-dev
#bundle install
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem 
is installed.

わけも分からず、rakeを実行。

#rake generate_session_store
Note: The rake task generate_session_store has been deprecated, please use the replacement version generate_secret_token
#RAILS_ENV=production rake db:migrate
Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.)
#gem install activerecord-mysql-adapter
#RAILS_ENV=production rake db:migrate
Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.)

以上のようにやっても駄目だった。ググってみると、mysql2を使えということだった。config/database.ymlを書き換えた。

$vi config/database.yml
production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmineuser
  password: "redminepass"
  encoding: utf8

そして、初期化スクリプトを実行する。すると、DB上にテーブルができたようだ。

#RAILS_ENV=production rake db:migrate

redmineが持っているウェブサーバを起動する。

#ruby script/server webrick -e production -p 8082
uby: No such file or directory -- script/server (LoadError)

あれ、script/serverというファイルなんかないよと言われる。確かになかった。

apacheとpassengerというのを使う。

参考:Redmine 2.2をCentOS 6.3にインストールする手順 | Redmine.JP Blog

#gem install passenger
#passenger-install-apache2-module
Here's what you can expect from the installation process:
 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 3. You'll learn how to deploy a Ruby on Rails application.
Checking for required software...
 * GNU C++ compiler... found at /usr/bin/g++
 * Curl development headers with SSL support... not found
 * OpenSSL development headers... found
 * Zlib development headers... found
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
 * Rake... found at /usr/local/rvm/wrappers/ruby-1.9.3-p362@redmine/rake
 * rack... found
 * Apache 2... found at /usr/sbin/apache2
 * Apache 2 development headers... not found
 * Apache Portable Runtime (APR) development headers... not found
 * Apache Portable Runtime Utility (APU) development headers... not found
Installation instructions for required software
 * To install Curl development headers with SSL support:
   Please run apt-get install libcurl4-openssl-dev or libcurl4-gnutls-dev, whichever you prefer.
 * To install Apache 2 development headers:
   Please run apt-get install apache2-prefork-dev as root.
 * To install Apache Portable Runtime (APR) development headers:
   Please run apt-get install libapr1-dev as root.
 * To install Apache Portable Runtime Utility (APU) development headers:
   Please run apt-get install libaprutil1-dev as root.
If the aforementioned instructions didn't solve your problem, then please take a look at the Users Guide:
  /usr/local/rvm/gems/ruby-1.9.3-p362@redmine/gems/passenger-3.0.18/doc/Users guide Apache.html
#aptitude install libcurl4-openssl-dev
#aptitude install libapr1-dev
#aptitude install libaprutil1-dev
#aptitude install apache2-prefork-dev
#passenger-install-apache2-module
--------------------------------------------
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
   LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p362@redmine/gems/passenger-3.0.18/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p362@redmine/gems/passenger-3.0.18
   PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p362@redmine/ruby
After 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!
--------------------------------------------
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:
   <VirtualHost *:80>
      ServerName www.yourhost.com
      # !!! Be sure to point DocumentRoot to 'public'!
      <Directory /somewhere/public>
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
      </Directory>
   </VirtualHost>
And that's it! You may also want to check the Users Guide for security and optimization tips, troubleshooting and other useful information:
  /usr/local/rvm/gems/ruby-1.9.3-p362@redmine/gems/passenger-3.0.18/doc/Users guide Apache.html
Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
https://www.phusionpassenger.com

よくわからないが、.htaccessの内容が動いていなかったので、動かすように。

#a2enmod rewrite
結局

Apacheからpassengerでredminerailsの動かし方がわからず、諦めました。