Redmine 3.0的需求:
http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Requirements
1. 搭建redmine3环境
【安装软件包】
# yum install zlib-devel gcc gcc-c++ make autoconf curl-devel ImageMagick-devel
【数据库】
若是全新安装:
mysql登录后,建立redmine数据库和用户:
mysql> create database redmine character set utf8;
mysql> grant all privileges on redmine.* to 'redmine'@'127.0.0.1' identified by 'redmine ';
mysql> exit;
【新建用户】
# useradd redmine
# chown -R redmine:redmine /home/redmine
【下载安装包,修改db和email的设置】
# tar -zxvf redmine-3.3.2.tar.gz
# cd redmine-3.3.2/config
# cp database.yml.example database.yml
production:
adapter: mysql2
database: redmine
host: 127.0.0.1
username: redmine
password: "redmine"
encoding: utf8
# cp configuration.yml.example configuration.yml
【建立ruby2.3 + rails 4.2的环境】
# gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# curl -ssL https://get.rvm.io| bash -s stable --ruby --rails
# source /etc/profile.d/rvm.sh
# rvm list known
# rvm install ruby-2.3
# ruby -v
# gem install rails
# rails -v
# rvm gemset list
# gem install bundler
# bundle install --without development test
# rvm install rubygems 2.6.10 --force
# rake generate_secret_token
(1)vi /usr/local/rvm/gems/ruby-2.3.3/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.rb
(2)按下Esc,输入 冒号 ,:set number
(3)找到第466行,把它用井号“#”注释掉
# RAILS_ENV=production rake db:migrate
# RAILS_ENV=production rake redmine:load_default_data
# mkdir -p tmp tmp/pdf public/plugin_assets
# chmod -R 755 files log tmp public/plugin_assets
若是升级:
【db】
备份数据库
检查db用户权限
命令行测试连接
执行:
# bundle exec rake generate_secret_token
# bundle exec rake db:migrate RAILS_ENV=production
若有插件:
# bundle exec rake redmine:plugins:migrate RAILS_ENV=production
# bundle exec rake tmp:cache:clear tmp:sessions:clear RAILS_ENV=production
启动服务:
# cd /home/redmine/
# ruby bin/rails server webrick -e production
也可以放入后台:
# nohup ruby bin/rails server webrick -e production >>/var/log/redmine/running_redmine.log 2>&1 &
# ruby bin/rails server webrick -e production -d
默认管理员:admin, admin
访问http://IP:3000
2. 迁移redmine服务到nginx下
# yum install nginx
# gem install passenger
# passenger -v
安装:
# passenger-install-nginx-module
Enter your choice (1 or 2) or press Ctrl-C to abort: 2
--------------------------------------------
Where is your Nginx source code located?
Please specify the directory: /data/download/nginx-1.6.2
--------------------------------------------
Where do you want to install Nginx to?
Please specify a prefix directory [/opt/nginx]: /etc/nginx
--------------------------------------------
Extra Nginx configure options
If you want to pass extra arguments to the Nginx 'configure' script, then
please specify them. If not, then specify nothing and press Enter.
If you specify nothing then the 'configure' script will be run as follows:
sh ./configure --prefix='/etc/nginx' --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-cc-opt='-Wno-error' --add-module='/usr/local/rvm/gems/ruby-2.2.0/gems/passenger-4.0.59/ext/nginx'
Extra arguments to pass to configure script: --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx
--------------------------------------------
Confirm configure flags
The Nginx configure script will be run as follows:
sh ./configure --prefix='/etc/nginx' --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-cc-opt='-Wno-error' --add-module='/usr/local/rvm/gems/ruby-2.2.0/gems/passenger-4.0.59/ext/nginx' --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx
--------------------------------------------
Nginx with Passenger support was successfully installed.
Please edit your Nginx configuration file,
and set the passenger_root and passenger_ruby configuration options in the
'http' block, like this:
http {
...
passenger_root /usr/local/rvm/gems/ruby-2.2.0/gems/passenger-4.0.59;
passenger_ruby /usr/local/rvm/gems/ruby-2.2.0/wrappers/ruby;
...
}
After you (re)start Nginx, you are ready to deploy any number of web
applications on Nginx.
Press ENTER to continue.
--------------------------------------------
Deploying a web application: an example
Suppose you have a web application in /somewhere. Add a server block
to your Nginx configuration file, set its root to /somewhere/public, and set
'passenger_enabled on', like this:
server {
listen 80;
server_name www.yourhost.com;
root /somewhere/public; # <--- be sure to point to 'public'!
passenger_enabled on;
}
And that's it! You may also want to check the Users Guide for security and
optimization tips and other useful information:
/usr/local/rvm/gems/ruby-2.2.0/gems/passenger-4.0.59/doc/Users guide Nginx.html
https://www.phusionpassenger.com ... 0guide%20Nginx.html
Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) 🙂
https://www.phusionpassenger.com
Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.
# useradd -s /sbin/nologin -M -c "nginx Server" nginx
# mkdir -p /etc/nginx/conf.d /data/log/svr/nginx /data/log/web/redmine
$ cat /etc/nginx/nginx.conf
#user nobody;
worker_processes 4;
error_log /data/log/svr/nginx/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /var/run/nginx.pid;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /data/log/svr/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_body_temp_path /tmp;
client_max_body_size 500m;
fastcgi_connect_timeout 600;
fastcgi_send_timeout 300;
fastcgi_read_timeout 3600;
fastcgi_buffer_size 400k;
fastcgi_buffers 16 1m;
fastcgi_busy_buffers_size 10m;
fastcgi_temp_file_write_size 20m;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_disable "MSIE [1-6].";
gzip_types text/plain application/x-javascript text/css text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
passenger_root /usr/local/rvm/gems/ruby-2.2.0/gems/passenger-4.0.59;
passenger_ruby /usr/local/rvm/gems/ruby-2.2.0/wrappers/ruby;
# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
include conf.d/*.conf;
}
$ cat /etc/nginx/conf.d/redmine.conf
#
# redmine
#
server {
listen 10.221.221.118:80;
server_name redmine.xxx.com;
root /data/website/redmine-3.0.0/public;
passenger_enabled on;
access_log /data/log/web/redmine/access.log main;
}