ruby 2.1 + rails 4.2+ mysql 5.6 +centos6.5 + rvm 1.29
1.基本的软件环境
yum -y install libyaml-devel zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel gcc ruby-devel gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA
2.配置redmine数据库(没装mysql的需先装mysql)
mysql> create user 'redmine'@'localhost' identified by 'redmine';
Query OK, rows affected (0.00 sec) mysql> create database redmine character set utf8;
Query OK, row affected (0.00 sec) mysql> grant all privileges on redmine.* to 'redmine'@'localhost';
Query OK, rows affected (0.00 sec) mysql> flush privileges;
Query OK, rows affected (0.00 sec)
3.iptables设置 (如果服务器开了防火墙,我们需要进行相关设置)
/sbin/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport -j ACCEPT /sbin/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport -j ACCEPT
4.安装php环境
yum -y install php php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-soap
5.安装ruby环境
\curl -L https://get.rvm.io | bash source /etc/profile.d/rvm.sh 查看已知的ruby版本
rvm list known 我安装的是2.1版本,可根据实际需求版本修改
rvm install 2.1
[root@collin ~]# ruby -v
ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-linux]
[root@collin ~]# rvm -v
rvm 1.29.1 (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]
6.安装rails
gem install rails 安装报错:版本不对
activesupport requires Ruby version >= 2.2.2.
**********************************
指定版本安装
gem install rails -v 版本号
gem uninstall rails -v 版本号
rails所有版本号
https://rubygems.org/gems/rails/versions/
**********************************
7.下载redmine
版本地址:http://www.redmine.org/releases/
wget http://www.redmine.org/releases/redmine-3.2.0.tar.gz tar zxvf redmine-2.6..tar.gz
8.依赖组件安装
cd redmine-2.6. gem install bundler bundle install --without development test rmagick(好多教程说要*,我貌似没有*也成功了。)
9:安装连接mysql的gem
gem install mysql2
10:配置redmine连接数据库
cd config
cp config/database.yml.example config/database.yml vim database.yml 修改下面相应的部分
production:
adapter: mysql2
database: redmine
host: 192.168.1.110
username: redmine
password: redmine
encoding: utf8
11:会话缓存
如果没有安装先安装
#gem install rake
#rake generate_secret_token 报错:
Could not find gem 'mysql2 (~> 0.3.11)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
根据提示安装
gem install mysql2 -v '0.3.11' 再执行
#rake generate_secret_token 可以会报一系列的错误 类似
Could not find gem 'simplecov (~> 0.9.1)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
执行这句就可修复上面的错误。
#bundle install
12:创建初始化所有redmine用到的table表
#RAILS_ENV=production rake db:migrate 报错:Mysql2::Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)......
First, go to database.yml
Change host: localhost
to host: 127.0.0.1
That's it!
重新执行
#RAILS_ENV=production rake db:migrate
13:装入默认的配置信息,输入zh(选择中文)
#RAILS_ENV=production rake redmine:load_default_data Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, es-PA, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] 手动输入zh
14:启动redmine
rails server webrick -e production
后台运行
rails server webrick -e production -d 启动Ok!用户名密码是 admin/admin 我的还是出问题了,本机可以访问远程死活访问不了。
加上-b 0.0.0.0
#rails server webrick -b 0.0.0.0 -e production
局域网电脑登录成功。 走了
启动指定访问端口81:rails server webrick -p81 -e production
另附:
查询已经安装的ruby
$ rvm list
卸载一个已安装版本
$ rvm remove 1.9.2
3、设置Ruby版本
RVM 装好以后,需要执行下面的命令将指定版本的 Ruby 设置为系统默认版本
$ rvm 2.0.0 --default
同样,也可以用其他版本号,前提是你有用 rvm install 安装过那个版本
这个时候你可以测试是否正确
$ ruby -v
参考文章
http://www.mrliangqi.com/813.html
https://my.oschina.net/smilelxb/blog/496763
http://blog.chinaunix.net/uid-26180298-id-3151871.html