-- Redmine

# nginx mysql 安装 google

useradd -g 100 -u 200 user_00

mkdir -p /usr/local/services/src

chown -R user_00.users /usr/local/services/

su - user_00; cd /usr/local/services/src


# Libyaml

wget -c http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz

tar xf yaml-0.1.4.tar.gz

cd yaml-0.1.4

./configure --prefix=/usr/local/services >/dev/null

make >/dev/null && make install >/dev/null

cd ..


# Imageagick

wget -c ftp://ftp.u-aizu.ac.jp/pub/graphics/p_w_picpath/ImageMagick/p_w_picpathmagick.org/ImageMagick-6.8.5-9.tar.gz

tar xf ImageMagick-6.8.5-9.tar.gz

cd ImageMagick-6.8.5-9

./configure --prefix=/usr/local/services/ >/dev/null

make >/dev/null && make install >/dev/null

cd ..


# Ruby

wget -c http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz

tar xf ruby-2.0.0-p0.tar.gz

cd ruby-2.0.0-p0

./configure \

CPPFLAGS=-I/usr/local/services/include \

--prefix=/usr/local/services \

--enable-shared \

--enable-pthread \

--disable-install-doc >/dev/null

make >/dev/null && make install >/dev/null

cd ..


# ruby config

sudo vim /etc/profile

# 文件尾增加

PATH=/usr/local/services/bin:$PATH

source /etc/profile

ruby --version

ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]


# 修改Ruby源

gem sources --remove http://rubygems.org/

gem sources -a http://ruby.taobao.org/

gem sources -l  # 确认修改成功否


# Rake/Rails

gem install rdoc

gem install rake

gem install rails


# redmine install

wget http://rubyforge.org/frs/download.php/76867/redmine-2.3.0.tar.gz

tar xf redmine-2.3.0.tar.gz

sudo mkdir -p /data/www/redm.domain.com

sudo chown -R user_00.users /data/www

cp -Rp redmine-2.3.0/* /data/www/redm.domain.com


# 修改bundle ruby源

cd /data/www/redm.domain.com

vim Gemfile

source 'http://ruby.taobao.org'


# 安装redmine 依赖

PKG_CONFIG_PATH=/usr/local/services/lib/pkgconfig gem install rmagick

bundle install


# 配置Redmine

mv config/database.yml.example config/database.yml  

vim config/database.yml

production:

 adapter: mysql2

 database: redmine

 host: 192.168.1.93

 username: rmuser

 password: rmpass

 encoding: utf8


# 创建DB用户

mysql -uroot -p

create database redmine character set utf8;

grant all privileges on redmine.* to 'redmu'@'192.168.1.96' identified by 'redmp';


# 生成会话存储

rake generate_secret_token


# 创建redmine表

RAILS_ENV=production rake db:migrate


# 启动

ruby script/rails server thin -e production -p 8000

http://ip:8000       # redmine页面正常, 至此redmine配置完成

-- Nginx+Thin


# 安装thin

sudo gem install thin


# thin install

sudo thin install

cd /data/www/redm.domain.com

thin -v     # 查看thin版本号

vim Gemfile

gem "thin", "~>1.5.1"


# thin config

# 监听方式

sudo thin config \

--config /usr/local/services/etc/thin.yml \

--chdir /data/www/redm.domain.com \

--pid log/thin.pid \

--log log/thin.log \

--user user_00 \

--group users \

--port 3001 \

--address 127.0.0.1 \

--servers 2 \

--max-conns 4096 \

--environment production


# --------------------------------------------------------------

# socket 方式

sudo thin config \

--config /etc/thin/thin.yml \

--chdir /data/www/redm.domain.com \

--pid log/thin.pid \

--log log/thin.log \

--user user_00 \

--group users \

--socket /dev/shm/thin.sock \

--servers 2 \

--max-conns 4096 \

--environment production


# 参数说明

--config        # 存放thin配置文件的目录

--chdir         # ruby项目目录

--pid           # thin 存放pid文件

--log           # thin 存放 log文件

--user          # thin 运行用户

--group         # thin 运行用户组

--port          # 监听端口

--address       # 监听地址

--max-conns     # 最大连接数

--environment   # 启用生产模式(development)


# thin 启动/停止脚本配置

mv /etc/rc.d/thin /etc/init.d/

vim /etc/init.d/thin


DAEMON=/usr/local/services/bin/thin

SCRIPT_NAME=/etc/init.d/thin

CONFIG_PATH=/etc/thin


# Nginx 配置

cd /usr/local/services/nginx-0.8.54/conf/

vim thin.conf


# 监听方式

vim thin.conf

upstream thin

{

   server 127.0.0.1:3001;

   server 127.0.0.1:3002;

}

# --------------------------------------------------------------

# SOCK 方式

vim thin.conf

upstream thinserver

{

   server unix:/dev/shm/thin.0.sock;

   server unix:/dev/shm/thin.1.sock;

}


# redmine nginx配置文件

vim vhosts/redm.domain.com

   server {

       listen       80;

       server_name  redm.domain.com;

       root         /data/www/redm.domain.com;


       location / {

           try_files         $uri @ruby;

           proxy_set_header  X-Real-IP  $remote_addr;

           proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;

           proxy_set_header  Host $http_host;

           proxy_redirect    off;

       }


       location @ruby {

           proxy_pass http://thinserver;

       }

   }


# 修改nginx.conf

vim nginx.conf

include thin.conf;

include vhosts/redm.domain.com;


# 重新加载nginx配置

nginx -s reload


# access

http://redm.domain.com


# 配置邮件功能

cd /data/www/redm.domain.com/config

vim configuration.yml

# 邮件配置


production:

   email_delivery:

       delivery_method: :smtp

       smtp_settings:

           address: "mail.domain.com"

           port: 25

           domain: 'domain.com'

           authentication: :login

           user_name: '[email protected]'

           password: '123456'


development:

   email_delivery:

       delivery_method: :smtp

       smtp_settings:

           address: "mail.domain.com"

           port: 25

           domain: 'domain.com'

           authentication: :login

           user_name: '[email protected]'

           password: '123456'


/etc/init.d/thin restart


# 邮件测试

   管理 -->配置 -->邮件通知 -->发送测试邮件

-- 安装问题


# WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true

'''

   vim /usr/local/services/lib/ruby/1.9.1/webrick/httpresponse.rb

   if chunked? || @header['content-length']  # 将这一行换成下面行

   if chunked? || @header['content-length'] || @status == 304 || @status == 204

'''


# /usr/local/services/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/connection.rb:31:in `post_init': cannot load such file -- thin/request (LoadError)

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/em/connection.rb:58:in `block in new'

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/em/connection.rb:49:in `instance_eval'

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/em/connection.rb:49:in `new'

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:1467:in `event_callback'

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/backends/base.rb:63:in `start'

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/server.rb:159:in `start'

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/controllers/controller.rb:86:in `start'

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/runner.rb:187:in `run_command'

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/runner.rb:152:in `run!'

#   from /usr/local/services/lib/ruby/gems/2.0.0/gems/thin-1.5.1/bin/thin:6:in `'

#   from /usr/local/services/bin/thin:23:in `load'

#   from /usr/local/services/bin/thin:23:in `

'

'''

cd /data/www/egaplay/redm.egaplay.com

vim Gemfile

thin -v      # 获取thin版本号

gem "thin", "~>1.5.1"

'''