1.gcc编译环境
$: yum -y install gcc
2.安装依赖组件
$: yum install flex autoconf zlib curl zlib-devel curl-devel bzip2 bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel gcc+ gcc-c++ libxml2 libxml2-devel libxslt libxslt-devel
3.安装libyaml-0.1.4
我们选择安装在/usr/local/src目录下
$: cd /usr/local/src
$: wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
$: tar xzvf yaml-0.1.4.tar.gz
$: cd yaml-0.1.4
$: ./configure --prefix=/usr/local
$: make
$: make install
4.安装libyaml-devel
本文安装在64位Linux系统上,故选择64位系统安装源
// 64位系统
$: su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm'
// 32位系统(32位系统选择此源安装)
$: su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm'
安装libyaml-devel
$: yum install libyaml-devel
5.安装MySql
本文mysql没有指定安装目录,默认安装在/var/lib/mysql
$: yum install mysql mysql-server mysql-devel
$: ls /etc/rc.d/init.d/mysqld -l
$: chkconfig --add mysqld
$: chkconfig mysqld on # 设置mysql开机启动
$: chmod 755 /etc/rc.d/init.d/mysqld # 修改mysql执行权限
// 启动mysql
$:service mysqld start
// 修改mysql密码
$: mysqladmin -uroot password '123456' # 123456为新设置的密码
// 命令行登录
$: mysql -uroot -p
Password 123456 # 输入刚新设置的密码
// 进行相关数据库配置
mysql > create database redmine character set utf8;
mysql > create user 'redmine'@'localhost' identified by 'redmine';
mysql > grant all privileges on redmine.* to 'redmine'@'localhost';
mysql > FLUSH PRIVILEGES;
mysql > exit; # 退出mysql
6.安装Ruby 1.9.3
我们选在安装在/usr/local/src目录下我们选在安装在/usr/local/src目录下
$: cd /usr/local/src
$: wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p547.tar.gz
$: tar zxvf ruby-1.9.3-p547.tar.gz
$: cd ruby-1.9.3-p547
$: ./configure --prefix=/usr/local/ruby --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib
$: make
$: make install
Ruby环境变量配置
$: vi /etc/profile
// 在文件末尾添加如下内容
RUBY_HOME=/usr/local/ruby
PATH=$PATH:$RUBY_HOME/bin
export RUBY_HOME PATH
//保存退出,操作:ESC -> :wq
$: source /etc/profile # 更新环境变量配置
测试ruby
$: ruby -v
ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-linux]
$: gem -v
1.8.23.2
ROOT环境变量操作
$: alternatives --install /usr/bin/ruby ruby /usr/local/ruby/bin/ruby 300
$: alternatives --install /usr/bin/gem gem /usr/local/ruby/bin/gem 300
7.安装Rails
$: gem install rails -v "3.2.17" -V # 安装指定的版本
8.安装Bundler
$: gem install bundler -V
$: alternatives --install /usr/bin/bundle bundle /usr/local/ruby/bin/bundle 300
9.安装Redmine、
9.1 准备工作
$: yum install ImageMagick-devel
9.2 我们选择安装在/usr/local/src目录下
$: cd /usr/local/src
$: wget http://www.redmine.org/releases/redmine-2.5.1.tar.gz
$: tar zxvf redmine-2.5.1.tar.gz
$: mv redmine-2.5.1 redmine
9.3 更改安装路径
$: mkdir /data
$: cd /data
$: mkdir www
$: cd /usr/local/src
$: mv /usr/local/src/redmine /data/www
9.4 修改配置文件
$: cd /data/www/redmine/config
// 修改配置信息文件
$: cp database.yml.example database.yml
// 进入修改
$: vim database.yml
// 修改内容如下
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "redmine"
encoding: utf8
development:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "redmine"
encoding: utf8
$: cd /data/www/redmine
$: vi Gemfile
// 修改内容如下
# gem "rmagick", ">= 2.0.0" // 注释掉这行,添加下面这行
gem "rmagick", :require => "RMagick"
9.5 安装Redmine的ruby组件
首先,我们需要除root以外的一位用户,如user1 创建user1
$: useradd -d /usr/user1 -g users -m user1
$: passwd user1
# 设置user1新密码
// 为user1添加sudo权限,该步骤在root用户下操作
$: chmod u+w /etc/sudoers # 添加sudo文件的写权限
$: vi /etc/sudoers
// 找到这行 root ALL=(ALL) ALL,在他下面添加:
user1 ALL=(ALL) ALL
$: chmod u-w /etc/sudoers # 撤销sudoers文件写权限
因为redmine在执行bunder install时是不能使用root权限来执行的,故我们更改权限给其他账户,如user1,我们更改redmine根目录权限给user1
$: cd /data/www
$: sudo chown -R user1:users redmine
进入redmine根目录,bundle执行注意不要使用root权限执行,在user1权限下执行
$: cd /data/www/redmine
$: su user1
$: bundle install
安装完毕如图:
9.6 生成安全Token,此时可切回root用户
$: su root
$: bundle exec rake generate_secret_token
9.7 生成数据表,导入初始化数据
$: cd /data/www/redmine/config
$: RAILS_ENV=production bundle exec rake generate_secret_token
$: RAILS_ENV=production bundle exec rake db:migrate
$: RAILS_ENV=production bundle exec rake redmine:load_default_data
// 这一步会让你选择 language,我们选择 zh 即可
9.8 激活FCGI4
$: cd /data/www/redmine/public
$: cp dispatch.fcgi.example dispatch.fcgi
$: cp htaccess.fcgi.example .htaccess
$: yum install epel-release
$: yum install mod_fcgid
9.9 Redmine配置
$: cd /data/www/redmine/config
$: cp configuration.yml.example configuration.yml
$: vi configuration.yml
// 修改内容如下
attachments_storage_path: /data/www/redmine/files # 冒号后面有个空格,不能漏
正式启动前关闭防火墙:
$: service iptables stop # 重启后失效
$: chkconfig iptables off # 禁用防火墙
10.启动Rdemine
$: cd /data/www/redmine
$: nohup bundle exec rails server webrick -p3000 -b 0.0.0.0 -e production >/dev/null 2>&1 &
若启动失败,可以执行如下代码查看报错,没有报错Ctrl + C 退出即可
$: bundle exec rails server webrick -e production
11.打开浏览器登录
浏览器地址为安装的主机IP:3000,如192.168.1.120:3000 默认账户名:admin,默认密码:admin
注意:在点击页面上的“帮助”时,页面会跳转到http://www.redmine.org/guide,此时登录账号时,IP为http://www.redmine.org/login,账号登录不了,我们必须将IP地址修改为http://192.168.1.120:3000/login,才能登录账号!
12.Redmine后台修改密码
$: cd /data/www/redmine/script
$: ./rails console production
// 进入ruby环境
ruby > admin_user = User.find_by_login('admin')
ruby > admin_user.password = 'password' # 登录密码修改为 password
ruby > admin_user.save!
ruby > quit
常见错误解决方案:
报错1:
运行bundle install时可能会遇到"Could not load OpenSSL."
解决方案:
$: yum install openssl openssl-devel
$: cd /usr/local/src/ruby-1.9.3-p547/ext/openssl
$: ruby extconf.rb
$: make && make install
报错2: 运行bundle install时可能会遇到
"Gem::InstallError: nokogiri requires Ruby version >= 2.1.0. An error occurred while installing nokogiri (1.8.1), and Bundler cannot continue. Make sure that gem install nokogiri -v '1.8.1' succeeds before bundling."
解决方案:
$: cd /data/www/redmine
$: vi Gemfile
// 修改内容如下
# gem "rmagick", :require => "RMagick" // 注释掉这行,修改为下面这行
gem "rmagick", ">= 2.0.0"
报错3:
运行RAILS_ENV=production bundle exec rake db:migrate时可能会遇到
"Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"
解决方案:
$: ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock