环境需求:
CentOS6.2 + ruby1.9.2 + rails3.2.6 + redmine2.0.3 + rubygems1.3.7 (版本很重要)
1、关掉selinux和iptables
sed -i s/\=enforcing/\=disabled/g /etc/selinux/config
chkconfig --level 35 iptables off
chkconfig --level 35 ip6tables off
2、安装相关的rpm包
yum -y install vim-enhanced wget ntp gcc gcc-c++ make automake autoconf mysql-devel libxml2-devel curl-devel patch libxslt-devel libxslt cyrus-sasl-devel openssh openssh-clients subversion pcre-devel httpd
3、安装ruby-1.9.2
tar zxvf ruby-1.9.2-p290.tar.gz
cd ruby-1.9.2-p290/
./configure
make && make install
cd ext/openssl
ruby extconf.rb
make && make install
ruby -v(检查安装版本)
#ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
4、安装rails3.2.6
gem install rails -v=3.2.6
5、安装mysql数据库
yum -y install mysql-server
mv /etc/my.cnf /etc/my.cnf.bak
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
chown -R mysql.mysql /var/lib/mysql
/usr/bin/mysql_install_db
service mysqld start
/usr/bin/mysqladmin -u root password '123456'
/usr/bin/mysql -u root -p123456
> create database redmine character set utf8;
> quit
6、安装redmine
wget http://rubyforge.org/frs/download.php/76259/redmine-2.0.3.tar.gz
tar zxvf redmine-2.0.3.tar.gz
cp -rf redmine-2.0.3 /var/www/html/redmine
cd /var/www/html/redmine/config/
cp database.yml.example database.yml
vi database.yml
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: redmine
encoding: utf8
## 注:文件内的adapter项要写mysql2,否则会报RuntimeError: Please install the mysql adapter: `gem install activerecord-mysql-adapter`
7、开始bundle install在执行bundle时要监测多项应用安装情况包括:mysql、postgresql、sqlite3、ImageMagick等,有一项没安装都会报错,解决思路:提示安装却什么,就安装什么。
yum -y install postgresql-server postgresql-devel
yum -y install ImageMagick ImageMagick-devel
yum -y install sqlite-devel
gem install pg -v '0.14.0'
gem install rmagick -v '2.13.1'
gem install sqlite3 -v '1.3.6'
bundle install --without development test (出现绿字侧成功)
8、配置redmine
rake generate_secret_token (生成会话存储密钥)
RAILS_ENV=production rake db:migrate (创建数据库结构)
RAILS_ENV=production rake redmine:load_default_data (载入默认配置,之后会有语言选择,选"zh")
ruby script/rails server webrick -e production (若是想webrick像服务一样启动加-d参数)
9、测试
http://localhost:3000
二、集成apache
Redmine默认使用RoR自带的web服务器WEBrick,默认的端口是3000,速度一般;很多人将Redmine集成到apache,nginx或 tomcat中,集成到apache通常采用CGI方式来集成,配置起来比较繁杂。Phusion Passenger组件是专门为apache和nginx开发的用来部署Ruby on Rails应用的,配置起来非常的方便,使用下来感觉页面的操作速度比WEBrick要快很多,本文记录了如何安装passenger来集成 Redmine到apache服务器。
环境信息:
CentOS6.2
Redmine 2.0.3
Passenger 3.0.14
1、安装依赖库
yum -y install httpd-devel apr-devel apr-util-devel
2、安装passenger
gem install passenger
passenger-install-apache2-module
3、修改apache配置文件
passenger成功安装后,它会给出如下的配置提示信息,需要将它们添加到apache的配置文件 /etc/httpd/conf/httpd.conf 中(不通版本目录名称不一样)
vi /etc/httpd/conf/httpd.conf
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.15/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.15
PassengerRuby /usr/local/bin/ruby
在httpd.conf中添加虚拟主机:
<virtualhost *:80>
ServerName redmine.
ServerAdmin admin@
DocumentRoot /var/www/html/redmine/public
ErrorLog logs/redmine_error_log
<directory "/var/www/html/redmine/public" >
Options Indexes ExecCGI FollowSymLinks -MultiViews
Order allow,deny
Allow from all
AllowOverride all
</directory>
</virtualhost>
3、重启apache
/etc/init.d/httpd restart
|