圖:Wikipedia

在 Ubuntu 用 apt-get 安裝 Redmine 並沒有很難:

$ sudo apt-get install apache2 libapache2-mod-passenger git subversion cvs mercurial redmine
$ sudo ln -s /usr/share/redmine/public /var/www/redmine
$ sudo vim /etc/apache2/mods-available/passenger.conf
<IfModule mod_passenger.c>
  PassengerDefaultUser www-data
  PassengerRoot /usr
  PassengerRuby /usr/bin/ruby
</IfModule>
$ sudo vim sudo vim /etc/apache2/sites-available/default
<Directory /var/www/redmine>
  RailsBaseURI /redmine
  PassengerResolveSymlinksInDocumentRoot on
</Directory>
$ sudo service apache2 reload

之後就可以用 http://localhost/redmine 逛了。此時的 rails 、 redmine 版本:

$ dpkg -l | grep redmine
ii redmine 1.3.2+dfsg1-1ubuntu1 flexible project management web application
ii redmine-sqlite 1.3.2+dfsg1-1ubuntu1 metapackage providing sqlite dependencies for Redmine
$ dpkg -l | grep rails
ii  ruby-rails-2.3 2.3.14-2 MVC ruby based framework geared for web application development

接著就要面對 Rails' Remote Code Execution Vulnerability Explained 問題了。所以,接下來就透過 gem 裝 rails 且從 github 取 redmine 安裝的筆記 :P

$ sudo apt-get install apache2 libapache2-mod-passenger git subversion cvs mercurial build-essential apache2-prefork-dev libaprutil1-dev libapr1-dev libcurl4-openssl-dev ruby-rvm ruby-dev gem libmagickwand-dev sqlite3 sqlite3-doc libsqlite3-ruby libsqlite3-dev
$ sudo gem install rails bundler passenger
$ sudo passenger-install-apache2-module
$ sudo vim /etc/apache2/mods-available/passenger.load
#LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
$ sudo vim /etc/apache2/mods-available/passenger.conf
<IfModule mod_passenger.c>
  #PassengerRoot /usr
  #PassengerRuby /usr/bin/ruby
  PassengerRoot /var/lib/gems/1.8/gems/passenger-3.0.19
  PassengerRuby /usr/bin/ruby1.8
</IfModule>

$ sudo mkdir -p /data/webapp
$ git clone git://github.com/redmine/redmine.git /data/redmine
$ cd /data/redmine
$ git branch local-config
$ git checkout local-config
$ vim config/database.yml
production:
  adapter: sqlite3
  database: db/redmine.db

development:
  adapter: sqlite3
  database: db/redmine.db
$ bundle install --without development test
$ ruby script/about
...
Environment:
  Redmine version                          2.2.2.devel
  Ruby version                             1.8.7 (x86_64-linux)
  Rails version                            3.2.11
  Environment                              production
  Database adapter                         SQLite
...
$ rake generate_secret_token
$ RAILS_ENV=production rake db:migrate
$ RAILS_ENV=production rake redmine:load_default_data
$ mkdir public/plugin_assets

此時,就可以透過 ruby webrick 簡易測試:

$ cd /data/redmine
$ ruby script/rails server webrick -e production

但終極目標還是跟 apache2 綁在一起 :P 這也是為何會安裝 passenger/libapache2-mod-passenger 這種東西,接著參考強者青蛙的 Virtualhost 設定方式:

$ mkdir /data/webapp
$ cd /data/webapp
$ ln -s ../redmine/public redmine
$ sudo vim /etc/apache2/conf.d/redmine 
<Virtualhost *>
  DocumentRoot /data/webapp
  RailsBaseURI /redmine
  <Directory /data/webapp/redmine>
    AllowOverride all
    Options -MultiViews
  </Directory>
</Virtualhost>
$ cd /data/redmine
$ sudo chown -R www-data:www-data files log tmp public/plugin_assets
$ sudo chmod -R 755 files log tmp public/plugin_assets
$ sudo service apache2 restart

補充:

使用 <Virtualhost *> 用法時,當啟用 http/https 後,我導致 https 出錯 :P 解法就是不要用 <Virtualhost *> 用法,而是直接去修改指定的地方,如 default 或 default-ssl 檔:

$ sudo vim /etc/apache2/conf.d/redmine
Alias /redmine "/path/redmine/public"
RailsBaseURI /redmine
<Directory /path/redmine/public>
  AssignUserId redmine service
  PassengerUploadBufferDir /path/redmine/PassengerUploadBufferDir
  AllowOverride all
  Options -MultiViews
</Directory>

接著再到 DocumentRoot 建立 symbolic link:

$ cd /var/www
$ ln -s /path/redmine/public redmine
$ mkdir -p /path/redmine/PassengerUploadBufferDir
$ chown redmine:service /path/redmine/PassengerUploadBufferDir


, , , ,

changyy 發表在 痞客邦 PIXNET 留言(0) 人氣()