centos环境下安装ruby+gem+rails+redmine2.4

于由 2014-03-10

#安装环境
32位 CentOS  6.3   或  32位 CentOS  6.0

postgresql 数据库
#------------------------------------------------------

#软件列表
yaml-0.1.4.tar.gz
openssl-1.0.1e.tar.gz
ruby-2.0.0-p353.tar.gz
redmine-2.4.2.tar.gz
#------------------------------------------------------

#创建基础目录
#------------------------------------------------------

cd /

mkdir /home/soft

mkdir -p /techcenter/sd/repos/

mkdir /techcenter/sd/conf

mkdir /techcenter/web

#ftp上传文件略

#安装yaml
#-------------------------------------------------------

cd /home/soft/

tar zxf yaml-0.1.4.tar.gz

./configure --prefix=/usr/local

make

make install

 
#安装openssl
#------------------------------------------------------

tar zxf openssl-1.0.1e.tar.gz

cd openssl-1.0.1e

./config --prefix=/usr/local/openssl --shared

make

make install

cd /usr/local/

ln -s openssl ssl

cd /etc/

vi ld.so.conf
#在include ld.so.conf.d/*.conf代码下面增加以下代码
/usr/local/openssl/lib

vi profile
#在文件最下面增加,以下代码
export OPENSSL=/usr/local/openssl/bin
export PATH=$OPENSSL:$PATH:$HOME/bin

ldconfig

#退出,重新终端命令窗口
exit

  

#安装ruby
#------------------------------------------------------

cd /home/soft/

tar zxf ruby-2.0.0-p353.tar.gz

cd ruby-2.0.0-p353

./configure --prefix=/usr/local/ruby-2.0 --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib

make && make install

echo "/usr/local/lib" >> /etc/ld.so.conf

vi /etc/profile
#在文件最下面增加下段代码
export PATH=/usr/local/ruby-2.0/bin:$PATH

source /etc/profile

exit

 
#配置ruby的openssl扩展
#------------------------------------------------------

cd /home/soft/ruby-2.0.0-p353/ext/openssl/

ruby extconf.rb --with-openssl-include=/usr/local/openssl/include/ --with-openssl-lib=/usr/local/openssl/lib

make && make install

ldconfig

exit

#更新Gem
#------------------------------------------------------
#检查当前gem版本

gem -v

gem update --system

gem -v

#安装rails
#------------------------------------------------------

#检查系统是否有rails及其版本
rails -v

#有则卸载,没有则安装3.2.16版本的rails
gem install rails -v 3.2.16

#漫长的等待中....终于更新完了.

rails -v

which rails
#/usr/local/ruby-2.0/bin/rails

yum install sqlite-devel

#测试rails
cd /techcenter/web/

vi Gemfile
#找到source 'https://rubygems.org',在下面增加下段代码
gem 'execjs'
gem 'therubyracer'
#保存并退出

bundle install

rails server

 
#可以通过浏览器,输入地址http://IP:3000/ 安装rails成功!


#安装Rmagick支持工具
#------------------------------------------------------

yum install freetype-devel ghostscript-devel jasper-devel lcms-devel libpng-devel libtiff-devel zlib-devel libxml2-devel

yum install ImageMagick-devel

gem install rmagick

  

#配置postgres数据库
#------------------------------------------------------

cd /home/pgadmin/

./psql -d postgres -Upgadmin

CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'redmine' NOINHERIT VALID UNTIL 'infinity';

CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;

yum install postgresql-devel

gem install pg

cd /usr/local/ruby-2.0/lib/ruby/gems/2.0.0/gems/pg-0.17.1/ext

ruby extconf.rb --with-pg-config=/usr/local/pgsql/bin/pg_config

make && make install

 
#配置redmine
#------------------------------------------------------

cd /techcenter/web/

cp /home/soft/redmine-2.4.2.tar.gz ./

tar -xvf redmine-2.4.2.tar.gz

rm -rf redmine-2.4.2.tar.gz

cd /techcenter/web/redmine-2.4.2/config

cp database.yml.example database.yml

vi database.yml
# 找到 PostgreSQL configuration example修改成下段代码
# 注意: 每一个冒号后面必须跟一个空格
production:
adapter: postgresql
database: redmine
host: localhost
username: redmine
password: "redmine"
encoding: utf8
#保存并退出

 
#编译并启动redmine
#------------------------------------------------------

cd /techcenter/web/redmine-2.4.2

bundle install --without development test rmagick

rake generate_secret_token

RAILS_ENV=production rake db:migrate

ruby script/rails server webrick -e production

#浏览器访问地址测试:http://IP:3000/  打开,即redmine安装成功!

相关推荐