在Ubuntu 16.04 LTS上安装redmine 3.2.0

1 准备工作

apt-get install libssl-dev libssl1.0.0 libaio-dev libaio1 libmagickcore-dev libmagickwand-dev imagemagick libcurl4-openssl-dev


2 安装Ruby

wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gz

tar -zxvf ruby-2.3.0.tar.gz

cd ruby-2.3.0

./configure

make

make install


3 修改gem源

gem source -r https://rubygems.org/

gem source -a https://ruby.taobao.org

gem update  

4 安装Rails

gem install bundler  

gem install rails


5 安装MySQL

下载 mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz

tar -zxvf mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz

mv mysql-5.7.12 /usr/local/mysql

cd /usr/local/mysql

建立mysql相关的用户和组,-s /sbin/nologin用于阻止用户登录

groupadd mysql

useradd -M -s /sbin/nologin -g mysql mysql

chown -R mysql .

chgrp -R mysql .

初始化数据

bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --secure-file-priv=/root/ --initialize

在初始化时如果加上 --initial-insecure,则会创建空密码的 root@localhost 账号;--secure-file-priv 指定密码文件夹位置 对应文件夹下就会有 .mysql_secret 文件。

配置

cp support-files/mysql.server /etc/init.d/mysqld

cp support-files/my-default.cnf /etc/my.cnf

在/etc/init.d/mysqld和/etc/my.cnf中都添加

basedir = /usr/local/mysql/

datadir = /usr/local/mysql/data

启动mysql服务

service mysqld start

登录,用/root/.mysql_secret文件中的密码

mysql -u root -p

修改密码

SET PASSWORD = PASSWORD('123456');

重新登录即可。

6 创建redmine数据库

CREATE DATABASE redmine CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'%' IDENTIFIED BY '123456';


6 安装Redmin

wget https://github.com/redmine/redmine/archive/3.2.0.tar.gz

tar -zxvf redmine-3.2.0.tar.gz

mv redmine-3.2.0 /usr/local/redmine

cd /usr/local/redmine
为redmine配置数据库连接:

cp config/database.yml.example config/database.yml

修改database.yml中“production”小结内容如下:

production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: 123456
  encoding: utf8

编辑redmine的Gemfile:

修改source为https://ruby.taobao.org

在“gem rbpdf”一行下面添加:
gem "rbpdf-font", "~> 1.19.0"

执行以下命令

gem install bundler

bundle install --without development test

rake generate_secret_token 

RAILS_ENV=production rake db:migrate 

RAILS_ENV=production rake redmine:load_default_data 

mkdir -p tmp tmp/pdf public/plugin_assets

配置邮件服务器和附件存放目录

cp config/configuration.yml.example config/configuration.yml

修改config/configuration.yml内容如下:

# = Redmine configuration file
#
# Each environment has it's own configuration options.  If you are only
# running in production, only the production block needs to be configured.
# Environment specific configuration options override the default ones.
#
# Note that this file needs to be a valid YAML file.
# DO NOT USE TABS! Use 2 spaces instead of tabs for identation.

# default configuration options for all environments
default:
  # Outgoing emails configuration
  # See the examples below and the Rails guide for more configuration options:
  # http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: xxx.163.com
      port: 25
      authentication: :login
      domain: xxx.com
      user_name: xxx
      password: xxx

  attachments_storage_path: /opt/redmine/files

# specific configuration options for production environment
# that overrides the default ones
production:

# specific configuration options for development environment
# that overrides the default ones
development:



测试,帐号:admin admin

ruby bin/rails server webrick -e production -b 0.0.0.0 -p 3000

7 迁移redmine服务到nginx下
gem install passenger

passenger-install-nginx-module

根据提示选择全新安装,安装位置/opt/nginx,安装完成后,进行配置

useradd -s /sbin/nologin -M -c "nginx server" nginx

chown -R nginx:nginx /usr/local/redmine

chown -R nginx:nginx /opt/nginx

mkdir -p /opt/redmine/files

chown -R nginx:nginx /opt/redmine

chmod -R 777 /opt/redmine

修改/opt/nginx/conf/nginx.conf内容如下

user  nginx;
worker_processes  4;

error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/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  logs/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/lib/ruby/gems/2.3.0/gems/passenger-5.1.7;
    passenger_ruby /usr/local/bin/ruby;

    #
    # redmine
    #
    server {
        listen       3000;
        server_name  redmine.xxx.com;
        root   /usr/local/redmine/public;
        passenger_enabled on;
        access_log  logs/redmine_access.log  main;
    }
}

最后启动nginx即可:

/opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf



你可能感兴趣的:(Project,Manage)