nginx + puma 部署 redmine2.6

人走茶凉 提交于 2020-10-28 10:10:13

#1.安装puma

$ gem install puma

因为文件是从amazon云上下载,所以经常是连不上去,重试几次就好了。

安装好以后的gems路径一般为:/usr/local/share/gems/gems/puma-2.9.2

#2.配置puma 在redmine的config目录下创建文件 puma.rb,如

$ vim /usr/local/redmine-2.6.0/config/puma.rb

application_path = '/usr/local/redmine-2.6.0'

directory application_path

environment 'production'

daemonize true

pidfile "#{application_path}/tmp/pids/puma.pid"

state_path "#{application_path}/tmp/pids/puma.state"

stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/

puma.stderr.log"

bind "unix://#{application_path}/tmp/sockets/redmine.sock" 

##3.安装gems

$ echo "gem: --no-ri --no-rdoc" >> ~/.gemrc

$ echo -e "# Gemfile.local\ngem 'puma'" >> Gemfile.local

$ bundle install --without development test

##4.运行puma

$  RAILS_ENV=production bundle exec puma -C ./config/puma.rb

##5. 错误处理

运行的时候会如下错误报错:

[root@www redmine-2.6.0]# RAILS_ENV=production bundle exec puma -C ./config/puma.rb
/usr/local/share/gems/gems/abrt-0.0.6/lib/abrt.rb:6:in `require': cannot load such file -- abrt/handler (LoadError)
	from /usr/local/share/gems/gems/abrt-0.0.6/lib/abrt.rb:6:in `block in <top (required)>'
/usr/local/share/gems/gems/puma-2.9.2/lib/puma/server.rb:18:in `require': cannot load such file -- puma/puma_http11 (LoadError)
	from /usr/local/share/gems/gems/puma-2.9.2/lib/puma/server.rb:18:in `<top (required)>'
	from /usr/local/share/gems/gems/puma-2.9.2/lib/puma/cli.rb:4:in `require'
	from /usr/local/share/gems/gems/puma-2.9.2/lib/puma/cli.rb:4:in `<top (required)>'
	from /usr/local/share/gems/gems/puma-2.9.2/bin/puma:6:in `require'
	from /usr/local/share/gems/gems/puma-2.9.2/bin/puma:6:in `<top (required)>'
	from /usr/local/bin/puma:23:in `load'
	from /usr/local/bin/puma:23:in `<main>'  

这是由于找不到puma/puma_http11模块。

将 /usr/local/share/gems/gems/puma-2.9.2/ext/puma_http11/puma_http11.so 拷贝到 /usr/local/share/gems/gems/puma-2.9.2/lib/puma 下就可以了。

##6. nginx配置

upstream puma_redmine {
  server unix:/usr/local/redmine-2.6.0/tmp/sockets/redmine.sock fail_timeout=0;
}

server {
  server_name YOUR.SERVER.NAME;
  listen 80;
  root /usr/local/redmine-2.6.0/public;

  location / {
      try_files $uri/index.html $uri.html $uri @ruby;
  }

  location @ruby {
  	proxy_set_header Host $http_host;
  	proxy_set_header X-Forwarded-Proto $scheme;
  	proxy_set_header X-Real-IP  $remote_addr;
  	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  	proxy_redirect off;
  	proxy_read_timeout 300;
  	proxy_pass http://puma_redmine;
  }
}

##7. 测试效果 简单测试了,性能似乎有所提升,但因为之前安装passenger+nginx的时候,经常是越用越慢,puma是否会出现这样的问题,后续再看。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!