2011/11/23

Redhat 安裝 Redmine

ssh root@server

cd /opt
wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm && rpm -i *.rpm

yum groupinstall "Development Tools"
yum install httpd httpd-devel
yum install libxml2 libxslt libxml2-devel libxslt-devel
yum install git
yum install openssl openssl-devel
yum install sqlite sqlite-devel 
yum install zlib zlib-devel 
yum install mysql++-devel mysql++ mysql-devel
yum install readline-devel compat-readline5 readline 
yum install libcurl libcurl-devel curl-devel 
yum install libstdc++ libstdc++-devel libstdc++-docs compat-libstdc++-33 
yum install apr-devel apr-util-devel

sudo https_proxy="YOUR_HTTPS_PROXY" bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

logout && login

rvm install 1.8.7
rvm --default system 1.8.7

logout && login

gem update system

which ruby
which gem

gem install passenger
passenger-install-apache2-module

chkconfig httpd on
service httpd restart

cd /opt && wget http://rubyforge.org/frs/download.php/75520/redmine-1.2.2.zip
unzip redmine-1.2.2.zip && mv redmine-1.2.2 /var/www/html/redmine && cd /var/www/html
cd /var/www/html/redmine/

touch Gemfile

vim Gemfile
###
source "http://rubygems.org"
gem "rake", "0.8.7"
gem "rack", "1.1.1"
gem "i18n", "0.4.2"
gem "rubytree", "0.5.2", :require => "tree"
gem "RedCloth", "~>4.2.3", :require => "redcloth" # for CodeRay
gem "mysql"
gem "coderay", "~>0.9.7"
# gem "rails", "2.3.11"
###

gem install bundler
bundle install

mysql -u root -p -h YOUR_SERVER
###
create database redmine character set utf8;
create user 'redmine'@'localhost' identified by 'YOUR_PASSWORD';
grant all privileges on redmine.* to 'redmine'@'localhost';
###

cd /var/www/html/redmine

mv config/database.yml.example config/database.yml
vim config/database.yml
###
production:
  adapter: mysql
  database: redmine
  host: YOUR_SERVER
  username: redmine
  password: YOUR_PASSWORD
  encoding: utf8
###

vim config/environment.rb
###
ENV['RAILS_ENV'] ||= 'production'
###

cd /var/www/html/redmine
RAILS_ENV=production bundle exec rake generate_session_store
RAILS_ENV=production bundle exec rake db:migrate
# RAILS_ENV=production bundle exec rake redmine:load_default_data

cd /var/www/html/redmine
mv public/dispatch.cgi.example public/dispatch.cgi
mv public/dispatch.fcgi.example public/dispatch.fcgi
mv public/dispatch.rb.example public/dispatch.rb
mv public/htaccess.fcgi.example public/.htaccess

cd /var/www/html/
chown -R apache:apache redmine
chmod -R 755 redmine

vim /etc/httpd/conf.d/redmine.conf
###
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9
PassengerRuby /usr/local/rvm/wrappers/ruby-1.8.7-p352/ruby

《Virtualhost *:80》
ServerName redmine
DocumentRoot /var/www/html/redmine/public
      《directory /var/www/html/redmine/public》
         AllowOverride all
         Options -MultiViews
      《/Directory》
《/VirtualHost》
###

service httpd restart

Upgrade

RAILS_ENV=production bundle exec rake generate_session_store
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake db:migrate:upgrade_plugin_migrations
RAILS_ENV=production bundle exec rake db:migrate_plugins
RAILS_ENV=production bundle exec rake tmp:cache:clear
RAILS_ENV=production bundle exec rake tmp:sessions:clear
service httpd restart

Reference:
http://gembundler.com/rationale.html
http://www.redmine.org/projects/redmine/wiki/RedmineInstall
http://www.redmine.org/projects/redmine/wiki/HowTos
http://www.redmine.org/projects/redmine/wiki/HowTo_install_Redmine_on_CentOS_5
http://www.redmine.org/projects/redmine/wiki/HowTo_have_both_development_and_production_environment_available_from_Apache_with_VirtualHost