参考
http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Installation
http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_using_Debian_package
第一步:安装数据库和redmine
安装mysql和redmine
apt-get install mysql;
apt-get install redmine;
第二步:配置数据库
CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
配置redmine的数据库
vim /usr/share/redmine/config/database.yml
写入
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: my_password
encoding: utf8
development:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: my_password
encoding: utf8
创建快捷方式
ln -s /usr/share/redmine/config/database.yml /etc/redmine/default/database.yml
进入redmine目录
cd /usr/share/redmine/
修改gemfile
vim Gemfile
添加
gem 'mysql2'
gem 'activerecord-mysql2-adapter'
第三步:安装包管理
执行
bundle install
第四步:session和 密匙
with Redmine 1.4.x:
with Redmine 2.x:
rake generate_session_store
with Redmine 2.x:
rake generate_secret_token
第五步:构造数据库
RAILS_ENV=production rake db:migrate
第六步:配置文件权限
mkdir -p tmp tmp/pdf public/plugin_assets
sudo chown -R redmine:redmine files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
第七步:安装thin 并配置
aptitude install thin;
新建redmine的thin配置文件
$ thin config --config /tmp/redmine.yml --chdir /usr/share/redmine --environment production --socket /var/run/redmine/sockets/thin.sock --daemonize --log /var/log/thin/redmine.log --pid /var/run/thin/redmine.pid --user root --group root --servers 1 --prefix /redmine
# mv /tmp/redmine.yml /etc/thin/redmine.yml
# chown root:root /etc/thin/redmine.yml
# chmod 644 /etc/thin/redmine.yml
启动thin 服务
thin restart -C /tmp/redmine.yml
第八步:配置nginx
新建1个nginx代理
vim /etc/nginx/proxy_opts
写入
# Shared options used by all proxies
proxy_set_header Host $http_host;
# Following headers are not used by Redmine but may be useful for plugins and
# other web applications
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Any other options for all proxies here
新建redmine的配置
vim /etc/nginx/sites-available/redmine
填写:
upstream redmine_thin_servers {
server unix:/var/run/redmine/sockets/thin.0.sock;
#server 127.0.0.1:3000;
#server unix:/tmp/thin.sock;
#server unix:/tmp/thin.1.sock;
#server unix:/tmp/thin.2.sock;
#server unix:/tmp/thin.3.sock;
# Add additional copies if using multiple Thin servers
#server unix:/var/run/redmine/sockets/thin.1.sock;
}
server {
listen 80; ## listen for ipv4
listen [::]:80 default ipv6only=on; ## listen for ipv6
# Set appropriately for virtual hosting and to use server_name_in_redirect
server_name localhost 192.168.49.119;
server_name_in_redirect off;
access_log /var/log/nginx/localhost.access.log;
error_log /var/log/nginx/localhost.error.log;
# Note: Documentation says proxy_set_header should work in location
# block, but testing did not support this statement so it has
# been placed here in server block
include /etc/nginx/proxy_opts;
proxy_redirect off;
# Note: Must match the prefix used in Thin configuration for Redmine
# or / if no prefix configured
location /redmine {
root /usr/share/redmine/public;
error_page 404 404.html;
error_page 500 502 503 504 500.html;
# Send sensitive stuff via HTTPS
# Remove if not using HTTPS
# Note1: Change $host to SSL CN if multiple host names used
# Note2: Adjust prefix, if different in Thin Redmine config
rewrite ^/redmine/login(.*) https://$host$request_uri permanent;
rewrite ^/redmine/my/account(.*) https://$host$request_uri permanent;
rewrite ^/redmine/my/password(.*) https://$host$request_uri permanent;
rewrite ^/redmine/admin(.*) https://$host$request_uri permanent;
try_files $uri/index.html $uri.html $uri @redmine_thin_servers;
}
location @redmine_thin_servers {
proxy_pass http://redmine_thin_servers;
}
}
# HTTPS server (Should match HTTP server above with a few differences)
# Optional. Remove rewrite directives above if not using.
server {
listen 443; ## listen for ipv4
listen [::]:443 default ipv6only=on; ## listen for ipv6
# Set appropriately for virtual hosting and to use server_name_in_redirect
server_name localhost 192.168.49.119;
server_name_in_redirect off;
access_log /var/log/nginx/localhost-ssl.access.log;
error_log /var/log/nginx/localhost-ssl.error.log;
# Note: Documentation says proxy_set_header should work in location
# block, but testing did not support this statement so it has
# been placed here in server block
include /etc/nginx/proxy_opts;
proxy_redirect off;
# Note: Adjust ssl_certificate{,_key} to custom SSL cert, if not
# using ssl-cert package
ssl on;
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
# Note: Must match the prefix used in thin configuration for redmine
# or / if no prefix configured
location /redmine {
root /usr/share/redmine/public;
error_page 404 404.html;
error_page 500 502 503 504 500.html;
try_files $uri/index.html $uri.html $uri @redmine_thin_servers;
}
location @redmine_thin_servers {
proxy_pass http://redmine_thin_servers;
}
}
创建web app配置快捷方式
rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/redmine /etc/nginx/sites-enabled/redmine
重启nginx
sudo service nginx restart
第九步:启动测试
浏览器输入http://192.168.49.119/redmine
补充
- ip部分大家修改为自己服务器或者虚拟机的地址
- email配置和脚本测试大家从官方文档中配置
- 如果配置有错误,欢迎留言补充说明