Nginx下Redmine配置

安装redmine依赖的所有ruby包

cd ..

gem install bundler #注意是在网站根目录下执行

bundle install --without development test rmagick #完成redmine依赖包的安装

bundler是用来管理ruby的包依赖的工具

为Rails生成cookies秘钥

rake generate_secret_token

创建数据库结构

RAILS_ENV=production rake db:migrate

生成缺省数据

RAILS_ENV=production REDMINE_LANG=zh rake redmine:load_default_data

调整文件系统权限

cd /data/wwwroot/redmine

mkdir -p tmp tmp/pdf public/plugin_assets

chown -R www.www /data/wwwroot/redmine

tmp和tmp/pdf (若不存在则创建该路径,用于生成 PDF 文件);public/plugin_assets (若不存在则创建该路径,plugins资源)

在WEBrick服务上测试 Redmine 是否安装成功

# vi /etc/passwd #使www用户有bash权限,lnmp脚本安装www用户没有bash权限

www:x:501:501::/home/www:/bin/bash

# su www -c "ruby script/rails server webrick -e production -d"

地址:http://IP:3000 (注意:打开iptables 3000端口号)

缺省管理员用户:

login: admin

password: admin

如果验证成功,则继续下面的步骤来使 Redmine 运行在Apache服务上

配置 Redmine 在Nginx上运行

结束webrick服务

cd /data/wwwroot/redmine/public/

cp dispatch.fcgi.example dispatch.fcgi

cp htaccess.fcgi.example .htaccess

chown -R www.www ./*

安装Passenger(用于整合Nginx)

gem install passenger

passenger-install-nginx-module

重新编译Nginx

cd ~/lnmp/src

cd nginx-1.6.2

/usr/local/nginx/sbin/nginx -V #查看已经编译参数

#在其后加上--add-module=/usr/local/ruby/lib/ruby/gems/2.1.0/gems/passenger-4.0.57/src/nginx_module参数,我的编译参数如下

./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module 

--with-http_spdy_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module 

--with-http_flv_module --with-ld-opt=-ljemalloc 

--add-module=/usr/local/ruby/lib/ruby/gems/2.1.0/gems/passenger-4.0.57/
src/nginx_module
make mv /usr/local/nginx/sbin/nginx{,_`date +%m%d`} cp objscp objs/nginx /usr/local/nginx/sbin/

配置Nginx

vi /usr/local/nginx/conf/nginx.conf#在http {}直接添加

passenger_root /usr/local/ruby/lib/ruby/gems/2.1.0/gems/passenger-4.0.57;

passenger_ruby /usr/local/ruby/bin/ruby;

添加虚拟主机(/usr/local/nginx/conf/vhost/bugs.linuxeye.com.conf)如下:

server {

listen 80;

server_name bugs.linuxeye.com;

access_log /data/wwwlogs/bugs.linuxeye.com_nginx.log combined;

index index.html index.htm index.jsp index.php;

include none.conf;

root /data/wwwroot/redmine/public;

passenger_enabled on;

}






upstream redmine{
  server 127.0.0.1:8000;
}
server {
l  isten 80;
  server_name redmine.happycity777.com;

  root /home/www/redmine/public;

  index index.html index.htm index.php;
  location / {
    try_files $uri @redmine;
  }
  location @redmine {
    proxy_pass http://redmine;
    proxy_redirect off;
    proxy_set_header Host $host; #注:这个不传进去,会暴露端口号,且会影响速度
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    # 如果找不到真实存在的文件,把请求分发至 index.php
    # try_files $uri $uri/ /index.php?$args;
  }

}

 
原文地址:https://www.cnblogs.com/grimm/p/5603310.html