Ubuntu 10.04安装Redmine 2.0与Apache2集成配置
零、注意事项
1、使用Ruby 1.9 + Redmine 2.0,有些插件安装时可能会出现问题,例如:
A、Scrum插件scrum-pm(redmine_sprints)
[html]
Error message:
no such file to load -- dispatcher
Exception class:
LoadError
Application root:
/usr/share/redmine
第三方库引用出现问题,可能是由Ruby 1.9较之前版本的改动引起。
scrum-pm官方并未说明支持Ruby 1.9,scrum-pm官方已经停止支持。
2、暂时建议使用低版本Ruby(1.8) 和 低版本Redmine(1.4)
www.zhishiwu.com
一、安装环境
1、操作系统
root@cloudsoft:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1 LTS
Release: 10.04
Codename: lucid
2、已经正常安装 MySql(sudo apt-get install mysql-server libmysqlclient-dev) :
root@cloudsoft:~# mysql --version
mysql Ver 14.14 Distrib 5.1.54, for debian-linux-gnu (i686) using readline 6.2
3、已经正常安装 Apache2
root@cloudsoft:~# apache2 -v
Server version: Apache/2.2.17 (Ubuntu)
Server built: Feb 22 2011 18:34:09
二、安装ruby 1.9 (含gem)
1、安装依赖包:
root@cloudsoft:~# sudo apt-get install gcc g++ build-essential libssl-dev libreadline-dev zlib1g-dev linux-headers-generic libyaml-dev
2、下载ruby 1.9 最新稳定版
root@cloudsoft:~# wget http://ftp.ruby-lang.org/pub/ruby/ruby-1.9-stable.tar.gz
root@cloudsoft:~# tar -zxf ./ruby-1.9-stable.tar.gz
www.zhishiwu.com
3、编译ruby源码
root@cloudsoft:~# cd ruby-1.9.3-p194/
root@cloudsoft:~/ruby-1.9.3-p194# ./configure --prefix=/usr/local/ruby
root@cloudsoft:~/ruby-1.9.3-p194# make && sudo make install
4、ruby环境变量设置
#PATH设置
root@cloudsoft:~/ruby-1.9.3-p194# sudo vi /etc/environment
#PATH中添加/usr/local/ruby/bin:
[plain]
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/ruby/bin"
root@cloudsoft:~/ruby-1.9.3-p194# source /etc/environment
#检查PATH设置
root@cloudsoft:~/ruby-1.9.3-p194# ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
root@cloudsoft:~/ruby-1.9.3-p194# gem -v
1.8.23
#修改GEM_HOME
root@cloudsoft:~/ruby-1.9.3-p194# sudo vim /etc/profile
#/etc/profile中添加:
[plain]
export GEM_HOME=/usr/local/ruby/lib/ruby/gems/1.9.1/
export RUBYOPT=rubygems
root@cloudsoft:~/ruby-1.9.3-p194# source /etc/profile
#修改 gem 源(你懂的)
root@cloudsoft:~# gem source
*** CURRENT SOURCES ***
www.zhishiwu.com
http://rubygems.org/
root@cloudsoft:~# gem source --clear-all
*** Removed specs cache ***
root@cloudsoft:~# gem source --add http://ruby.taobao.org/
http://ruby.taobao.org/ added to sources
5、安装bundler
root@cloudsoft:~# gem install bundler
root@cloudsoft:~# ln -s /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/bin/bundle /usr/local/ruby/bin/bundle
三、安装redmine 2.0.3
1、下载redmine
root@cloudsoft:~# git clone https://github.com/redmine/redmine.git
root@cloudsoft:~# mv -f ./redmine/ /usr/share/redmine
root@cloudsoft:~# cd /usr/share/redmine/
root@cloudsoft:/usr/share/redmine# rm -Rf ./.git
2、修改Gemfile
root@cloudsoft:/usr/share/redmine# vim ./Gemfile
#将source 修改为http://ruby.taobao.org/(我们都懂)
[plain]
source 'http://ruby.taobao.org/'
www.zhishiwu.com
#若是用mysql可以将postgresql相关注释掉
[plain]
# Database gems
#platforms :mri, :mingw do
# group :postgresql do
# gem "pg", ">= 0.11.0"
# end
3、安装redmine 依赖包
#可能出现的错误(错误可能会非常多,慢慢解决吧,以下几个典型):
A、An error occured while installing mysql2 (0.3.11), and Bundler cannot continue.
#请先安装libmysqlclient-dev
root@cloudsoft:~# sudo apt-get install libmysqlclient-dev
B、An error occured while installing pg (0.14.0), and Bundler cannot continue.
#使用mysql的可以将pg从Gemfile中删除,或者安装postgresql,我选择不安装pg
C、An error occured while installing rmagick (2.13.1), and Bundler cannot continue.
#需要安装imagemagick
root@cloudsoft:~# sudo apt-get install imagemagick
3、数据库创建、配置(myql)
root@cloudsoft:/usr/share/redmine# mysql -p
[sql]
create database redmine character set utf8;
create user 'redmine'@'localhost' identified by 'my_password';
grant all privileges on redmine.* to 'redmine'@'localhost';
www.zhishiwu.com
root@cloudsoft:/usr/share/redmine# cp config/database.yml.example config/database.yml
root@cloudsoft:/usr/share/redmine# vim config/database.yml
[plain]
production:
adapter: mysql2 #ruby1.9使用mysql2
database: redmine
host: localhost
username: redmine
password: my_password
root@cloudsoft:/usr/share/redmine# rake generate_secret_token
#创建数据库
root@cloudsoft:/usr/share/redmine# RAILS_ENV=production rake db:migrate
root@cloudsoft:/usr/share/redmine# RAILS_ENV=production rake redmine:load_default_data
4、修改用户权限
root@cloudsoft:/usr/share/redmine# mkdir tmp public/plugin_assets
#为了使用apache2,将redmine的运行用户设置为www-data
root@cloudsoft:/usr/share/redmine# sudo chown -R www-data:www-data files log tmp public/plugin_assets
root@cloudsoft:/usr/share/redmine# sudo chmod -R 755 files log tmp public/plugin_assets
5、试运行
root@cloudsoft:/usr/share/redmine# ruby script/rails server webrick -e production
#浏览器访问:http://192.168.1.203:3000/ 确认是否可以正常运行
四、Apache集成
使用webrick运行redmine 奇慢无比,所以使用Apache。
1、安装Apache passenger模块
root@cloudsoft:~# gem install passenger
root@cloudsoft:~# passenger-install-apache2-module
#按照提示检查所需依赖包安装情况,若有尚未安装的包,根据提示安装即可
#安装完毕它会提醒我们如何配置Apache,可参考
www.zhishiwu.com
2、修改Apache Mode配置
root@cloudsoft:~# vim /etc/apache2/mods-enabled/passenger.conf
[plain]
<IfModule mod_passenger.c>
PassengerRoot /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.15/
PassengerRuby /usr/local/ruby/bin/ruby
PassengerDefaultUser www-data
</IfModule>
root@cloudsoft:~# vim /etc/apache2/mods-enabled/passenger.load
[plain]
LoadModule passenger_module /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.15/ext/apache2/mod_passenger.so
3、Apache虚拟主机配置
#在Apache虚拟主机目录下创建符号链接
root@cloudsoft:~# ln -s /usr/share/redmine_2/public /var/www/redmine
#修改虚拟主机配置文件
root@cloudsoft:~# vim /etc/apache2/sites-enabled/000-default
[plain]
<VirtualHost *:80>
ServerAdmin simba@cloudsofts.com
DocumentRoot /var/www
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ErrorLog /var/log/apache2/error.log
#其他配置 foo...
<Directory /var/www/redmine>
Options +ExecCGI -MultiViews
AllowOverride all
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
</Directory>
</VirtualHost>
www.zhishiwu.com
4、重启Apache
root@cloudsoft:~# /etc/init.d/apache2 reload
五、END
enjoy
六、参考:
http://www.redmine.org/projects/redmine/wiki/RedmineInstall
http://blog.csdn.net/berryreload/article/details/7179969
http://linuxiou.blog.51cto.com/1262466/867790
http://stackoverflow.com/questions/11439207/rails-error-installing-pg-gem
http://clark1231.iteye.com/blog/1504019
作者 yuleslie