安裝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;
}
}