Redmine比BoardReview还要折腾,主要是让apache支持Redmine(即不通过3000端口访问,通过80端口访问),总是提示错误。后来查看apache的错误日志,才知道需要修改:
1. config/environment.rb,指定环境变量。ENV['RAILS_ENV'] ||= 'production'
2. public/dispatch.fcgi,加载rubygems和fcgi模块。
一种方式是安装完Redmine后通过3000访问,这个据说性能低;所以改为Apache的cgi支持的方式。
Redmine单独启动
echo "for Centos6 x86_64bit. Centos5.5因为Python是2.4的,无法支持ReviewBoard。"
echo "refer to: http://www.redmine.org/projects/redmine/wiki/RedmineInstall"
echo "refer to: http://www.redmine.org/projects/redmine/wiki/Redmine_on_CentOS_installation_HOWTO"
# 安装支持工具
# redmine 2.2.1 requires following:
sudo yum -y install zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel
# install ruby(ruby 1.8.7), it canbe ruby 1.8.7, 1.9.2, 1.9.3, jruby-1.6.7
sudo yum install -y ruby ruby-devel
# install gems(RubyGems <= 1.8)
sudo yum install -y rubygems
# install mysql
sudo yum install -y mysql-server
# 将mysql的编码改为utf8,否则中文会出现乱码,修改/etc/my.conf
sudo vi /etc/my.cnf
#修改内容,在以下两节中添加:
[mysqld]
default-character-set=utf8
[client]
default-character-set=utf8
sudo chkconfig mysqld on
sudo service mysqld start
# install passenger
sudo gem install passenger
echo "very important to run redmine on apache. choose 1 to install passenger for apache."
sudo passenger-install-apache2-module
#下载和解压Redmine
##################################################################################
##################################################################################
wget http://rubyforge.org/frs/download.php/76677/redmine-2.2.1.tar.gz
tar xf redmine-2.2.1.tar.gz
sudo mkdir /var/www/redmine
sudo cp -a redmine-2.2.1/* /var/www/redmine
# 安装Redmine
##################################################################################
##################################################################################
# install rmagick
sudo yum install -y ImageMagick-devel postgresql-devel sqlite-devel
# install bundler
sudo gem install bundler pg sqlite3
# update gem file, [winlin] do nothing.
#vi /var/www/redmine/Gemfile
# bundle install
cd /var/www/redmine
sudo bundle install
# bundle show mysql
# 创建数据库
##################################################################################
##################################################################################
# set mysql user name to root, password to root.
mysqladmin -uroot -p"" password root
# create database, login as root of mysql
mysql -uroot -proot
create database redmine character set utf8;
create user 'redmine'@'localhost' identified by 'my_password';
\q
# config database
cd /var/www/redmine/config
sudo cp database.yml.example database.yml
sudo vi database.yml
# 修改用户名和密码。
#单独启动Redmine,侦听3000端口。
# 访问方式:http://redmine:3000
##################################################################################
##################################################################################
cd /var/www/redmine
# generate database data
sudo rake generate_secret_token
# 以下以root用户运行。sudo su
RAILS_ENV=production rake db:migrate
RAILS_ENV=production REDMINE_LANG=fr rake redmine:load_default_data
# config svn
cd /var/www/redmine/config
cp configuration.yml.example configuration.yml
# test install
cd /var/www/redmine
sudo ruby script/rails server webrick -e production
echo "Redmine is running..."
Apache和Redmine
# Redmine的Apache支持,通过Apache访问,不单独启动Redmine
##################################################################################
##################################################################################
echo "refer to: http://www.redmine.org/projects/redmine/wiki/HowTo_configure_Apache_to_run_Redmine"
# install cgis.
cd /var/www/redmine/public
cp dispatch.fcgi.example dispatch.fcgi
cp htaccess.fcgi.example .htaccess
# change owner.
cd /var/www
sudo chown -R apache:apache redmine
sudo chmod -R 755 redmine
# config ruby
cd /var/www/redmine
# add the following to the first line of file: config/environment.rb
sudo vi config/environment.rb
cat << END
ENV['RAILS_ENV'] ||= 'production'
END
# add the following lines to the file: public/dispatch.fcgi
sudo vi public/dispatch.fcgi
cat << END
require 'rubygems'
require 'fcgi'
END
# 安装fastcgi/fcgi/mode_fastcgi支持
##################################################################################
##################################################################################
# install fastcgi for apache.
cd; wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
tar xf mod_fastcgi-current.tar.gz
(cd mod_fastcgi-2.4.6; cp Makefile.AP2 Makefile;)
# lib64, if 32bit os, use /usr/lib/httpd instead
(cd mod_fastcgi-2.4.6; make top_dir=/usr/lib64/httpd;)
(cd mod_fastcgi-2.4.6; sudo make install top_dir=/usr/lib64/httpd)
# install to apache
sudo vi /etc/httpd/conf.d/mod_fastcgi.conf
cat << END
LoadModule fastcgi_module modules/mod_fastcgi.so
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
</IfModule>
END
# restart apache
sudo /sbin/service httpd restart
sudo chmod 777 /tmp/fcgi_ipc -R
sudo /sbin/service httpd restart
# install fcgi for ruby(redmine)
cd; wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar -zxvf fcgi-2.4.0.tar.gz
# patch it, 或者用我们已经下载修改的包。
cd fcgi-2.4.0;
vi include/fcgio.h
echo "在第34行加上以下include"
#include <cstdio>
echo "为了支持新版的gcc。"
# make and install.
(cd fcgi-2.4.0;./configure;)
(cd fcgi-2.4.0;make; sudo make install)
sudo gem install fcgi
# update apache config
sudo vi /etc/httpd/conf/httpd.conf
cat << END
<VirtualHost *:80>
ServerName redmine.winlin.com
ServerAdmin webmaster@winlin.com
DocumentRoot /var/www/redmine/public/
ErrorLog logs/redmine_error_log
<Directory "/var/www/redmine/public/">
Options Indexes ExecCGI FollowSymLinks
Order allow,deny
Allow from all
AllowOverride all
</Directory>
</VirtualHost>
END
# 完毕,重启Apache
# 可通过: http://server 访问
##################################################################################
##################################################################################
sudo /sbin/service httpd restart