Redmine 是一套使用 Ruby 語言開發的專案管理系統,它非常好用!
在 Ubuntu 環境安裝 Redmin 專案管理系統,需要先佈置好 Ruby 環境。
可以參考:
http://zx-1986.blogspot.com/2010/09/ruby-on-rails-in-ubuntu.html[LAMP 環境]
架設 Ubuntu Web Server[安裝 Ruby]
sudo apt-get install ruby
sudo apt-get install ruby-dev
sudo apt-get install irb libruby libopenssl-ruby ri rdoc
sudo apt-get update
[安裝 RubyGems]
sudo su -
cd /opt
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz
tar zxvf rubygems*
cd rubygems*
ruby --version
ruby setup.rb --help
ruby setup.rb
ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo apt-get install rubygems# 註:如果可以,盡量使用 Ruby 來編譯安裝 RubyGems
[安裝需要的 Gems]
sudo su -
gem install -v=0.8.7 rake
gem install -v=1.1.1 rack
gem install -v=0.4.2 i18n
gem install -v=2.3.11 rails
# 註:打包好的 Redmine 內(非原始碼包)已經自帶了 Rails(vendor/rails)
# Gems 預設會放在:/usr/lib/ruby/gems/1.8
[SQLite 資料庫]
假設是使用 sqlite3,需要補充必要套件:
sudo apt-get install sqlite3 sqlite3-doc
sudo apt-get install libsqlite3-ruby
[下載 Redmine 程式]
cd /var/www/
wget http://rubyforge.org/frs/download.php/75099/redmine-1.2.1.zip
unzip redmine*.zip
mv redmine*.zip /tmp
mv redmine* redmine
使用 svn 直接同步 Redmine 的線上原始檔,所以先安裝 svn:
sudo apt-get install subversion
假設要將 Redmine 部署在 /var/www/ 底下,執行:
cd /var/www
svn checkout http://redmine.rubyforge.org/svn/branches/1.1-stable redmine-1.1
[Redmine 的資料庫設定]
修改 conf 資料夾下的 database.yml:
cd /var/www/redmine/config
cp database.yml.example database.yml
vim database.yml
將 database.yml 預設 MySQL (default setup) 內容全部註解起來。
檔案最開頭,補上:
production:
adapter: sqlite3
database: db/redmine.db
development:
adapter: sqlite3
database: db/redmine.db
[相關的資料夾設置]
cd /var/www/redmine
mkdir -p tmp public/plugin_assets
sudo chown -R www-data.www-data files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
[執行 Rake 進行部署]
chown -R www-data.www-data /var/www/redmine # 避免權限問題,把 Redmine 給 HTTP Server 控制者
cd /var/www/redmine
ruby script/about
/var/lib/gems/1.8/bin/rake generate_session_store # Ubuntu Desktop
RAILS_ENV=production /var/lib/gems/1.8/bin/rake db:migrate
RAILS_ENV=production /var/lib/gems/1.8/bin/rake redmine:load_default_data
Ubuntu 系統預設不會把 /var/lib/gems/1.8/bin 加到環境路徑。
所以呼叫 Rake 程式時,需要使用絕對路徑:/var/lib/gems/1.8/bin/rake
當然,你可以選擇把這個路徑加到系統的 PATH 變數 [Ref. 03]。
或者,直接使用 apt-get 安裝一個系統層級的 Rake 套件,但不建議 [Ref. 04]。
在 Ubuntu Server 版的環境中,Rake 的絕對路徑預設是:
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake
[測試 Redmine]
使用 Ruby 附帶的 WEBrick Web Server 測試啓動 Redmine:
cd /var/www/redmine
ruby script/server webrick -e production
預設的連結是本地端的 3000 埠:
http://localhost:3000預設管理者的帳號密碼是:
admin/admin
Redmine 佈景主題安裝很簡單,推薦一個不錯的:
Pixel Cookers將佈景主題下載到 /var/www/redmine/public/themes 下,解壓縮就可以用了。
Redmine 主頁面的 html 可以修改這個檔案:
/var/www/redmine/app/views/layouts/base.rhtml
*
【run with Apache】
補充必要套件:
sudo apt-get install build-essential
sudo apt-get install apache2-prefork-dev libaprutil1-dev libapr1-dev libcurl4-openssl-dev
使用 RubyGems 安裝 Phusion Passenger 及其 Passenger Apache2 Module。
Passenger 也叫做 mod_rails 或 mod_rack,類似 mod_ruby 那種角色。
Passenger Apache2 Module 安裝過程會出現互動選項,請務必謹慎閱讀與選擇。
不同環境的執行結果或許有出入,以下僅記錄我個人環境執行的訊息:
sudo gem install passenger
sudo /var/lib/gems/1.8/bin/passenger-install-apache2-module
Passenger 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.
# 安裝會完成的三件事。
Don't worry if anything goes wrong. This installer will advise you on how to solve any problems.
# 都說 do not worry 了,那就 do not worry 吧!哈哈!
# 如果真的出現什麼問題,就照它指示的修正,然後再重新執行安裝。
編譯與佈置完成後出現的訊息:
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
# 下面這三行是要寫到 /etc/apache2/apache2.conf 的。
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-3.0.2/ext/apache2/mod_passenger.so
PassengerRoot /var/lib/gems/1.8/gems/passenger-3.0.2
PassengerRuby /usr/bin/ruby1.8
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:
# 在 /etc/apache2/sites-available 底下新增一個檔案叫:redmine
# 並且把底下這段複製貼到 redmine 這個虛擬主機設定檔
<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>
# 注意!裡面的 /somewhere/public 要改成 /var/www/redmine/public 的絕對路徑
# ServerName 可以設定成 localhost
# 因爲技術問題,請自行把上文全形的<>換成 <>
當 /etc/apache2/apache2.conf 與 /etc/apache2/site-available/redmine 都配置好。
執行:
sudo chown -R www-data:www-data /var/www/redmine
sudo a2ensite redmine
sudo service apache2 restart
連線
http://localhost:80 測試。
Reference:
01.
http://www.redmine.org/projects/redmine/wiki/RedmineInstall02.
http://www.redmine.org/projects/redmine/wiki/RedmineRepositories03.
http://stackoverflow.com/questions/1664974/rake-command-not-found04.
http://fak3r.com/geek/ruby-on-rails-gem-install-versus-apt-get05.
http://www.redmine.org/issues/832506.
http://www.redmine.org/boards/2/topics/2613807.
http://jugemchosuke.blogspot.com/2011/06/redmine-1.html