此部分描述了redmine服务器的部署过程。主要涉及mysql,ruby,rubygem,rails,redmine,apache及mongrel的安装和配置。为了便于管理,采用编译安装。在配置环境的过程中,最好按照如下的顺序进行,避免由于软件之间的依赖关系而出错。
假设以下的安装程序放在/home/work/tools文件夹下。
创建apache安装后的目录,/home/work/oem/apache
1、编译安装apr
cd /home/work/tools
tar –xzvf apr-1.4.8.tar.gz
cd apr-1.4.8
./configure --prefix=/home/work /oem/apache/apr
make
make install
2、编译安装apr-util
cd /home/work/tools
tar –xzvf apr-util-1.5.2.tar.gz
cd apr-util-1.5.2
./configure--prefix=/home/work/oem/apache/apr_util --with-apr=/home/work/oem/
apache/apr
make
make install
3、编译安装apache
cd /home/work/tools
tar –xzvf httpd-2.2.21.tar.gz
cd httpd-2.2.21
./configure --prefix=/home/work/oem/apache--enable-mods-shared=all --enable-so --with-mpm=worker --enable-deflate--enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-proxy--enable-rewrite --enable-charset-lite --enable-suexec--with-suexec-bin=/usr/sbin/suexec --disable-ipv6 -disable-dav --with-apr=/home/work/oem/apache/apr --with-apr-util=/home/work/oem/apache/apr
-util/ --sysconfdir=/home/work/oem / apache/conf
make
make install
更改apache配置
cd /home/work/oem /apache/conf
vimhttpd.conf
Listen 80 改为 Listen 8080 #只有root用户才能启动80端口
cd /home/work/oem / apache/bin
./httpd –k start #启动apache服务器
访问服务器的8080端口,如cp01-sys-ra09-jueheng2qa078.cp01.baidu.com:8080,确认apache可正常启动。
安装完成后建议把apache加入到系统路径中去,这样就可以直接使用httpd命令了,方法如下:
cd /home/work/&& vim ./.bashrc #编辑bashrc文件
export PATH=/home/work/oem/apache/bin:$PATH #在bashrc文件中加入以下语句
cd /home/work/tools
tar –xzvf mysql-5.1.66.tar.gz
cd mysql-5.1.66
./configure--prefix=/home/work/oem/mysql/ --with-charset=utf8
--with-extra-charsets=gbk,utf8,ascli,big5,latin1,binary--with-unix-socket-path=/home/work /oem/mysql/mysql.sock
make
make install
cd/home/work /oem/mysql && mkdir data #创建data目录用于存放数据库
cd /home/work/oem/mysql/bin
./mysql_install_db --user=root --basedir=/home/work/oem/mysql
--datadir=/home/work/oem/mysql/data #初始化数据库
cp /home/work/oem/mysql/share/mysql/my-medium.cnf /home/work/oem/mysql/my.cnf#配置文件
/home/work/oem/mysql/bin/mysqld_safe –defaults-file=/home/work/oem/mysql/my.cnf& #启动mysql后台运行并指定配置文件
ps –ef | grep mysql #查看mysql服务器是否已经启动
/home/work /oem/mysql/bin/mysqladmin version #验证服务器是否在运行
/home/work/oem/mysql/bin/mysql –uroot #登录mysql
安装完成后建议把mysql加入到系统路径中去,这样就可以直接使用mysql命令了,方法如下:
cd /home/work/&& vim ./.bashrc #编辑bashrc文件
exportPATH=/home/work/oem/mysql/bin:$PATH #在bashrc文件中加入以下语句
cd /home/work/tools
tar –xzvf ruby-1.8.7-p357.tar.gz
cd ruby-1.8.7-p357
./configure --prefix=/home/work/oem/ruby
make
make install
cd /home/work/oem/ruby/bin
ruby –v #检测ruby是否安装正常
irb #可进入ruby的控制台
安装完成后建议把ruby加入到系统路径中去,这样就可以直接使用ruby命令了,方法如下:
cd /home/work/&& vim ./.bashrc #编辑bashrc文件
export PATH=/home/work/oem/ruby/bin:$PATH #在bashrc文件中加入上述语句
rubygems是ruby的在线包管理工具,用来安装rails所需的各种组件。
cd /home/work/tools
tar –xzvf rubygems-1.4.2.tar.gz
cd rubygems-1.4.2
ruby setup.rb
所有需要安装的gem包,均放在/home/work/tools/gem中。
cd /home/work/tools/gem
gem install rake-0.8.7.gem
gem install activesupport-2.3.5.gem
gem install activerecord-2.3.5.gem
gem install rack-1.0.1.gem
gem install actionpack-2.3.5.gem
gem install actionmailer-2.3.5.gem
gem install activeresource-2.3.5.gem
gem install rails-2.3.5.gem
gem install i18n-0.4.2.gem
gem install cgi_multipart_eof_fix-2.5.0.gem
gem install daemon_controller-1.1.4.gem
gem install daemons-1.1.9.gem
gem install erubis-2.7.0.gem
gem install fastercsv-1.5.5.gem
gem install fastthread-1.0.7.gem
gem install gem_plugin-0.2.3.gem
gem install importex-0.1.1.gem
gem install jdbc-mysql-5.1.25.gem
gem install json-1.8.0.gem
gem install json_pure-1.8.0.gem
gem install mail-2.5.4.gem
gem install mime-types-1.23.gem
gem install mysql-2.8.1.gem
gem install parseexcel-0.5.2.gem
gem install polyglot-0.3.3.gem
gem install RedCloth-4.2.9.gem
gem install ruby-mysql-2.9.11.gem
gem install ruby-ole-1.2.11.7.gem
gem install ruby-pinyin-0.2.4.gem
gem install rubytree-0.8.3.gem
gem install spreadsheet-0.9.6.gem
gem install structured_warnings-0.1.4.gem
gem install treetop-1.4.14.gem
gem install will_paginate-2.3.16.gem
gem install yard-0.8.6.1.gem
gem install mongrel-1.1.5.gem
安装完成后,可通过gem list查看已经安装的gem包,以上的文件均被安装在 /home/work/oem/ruby/lib/ruby/gems/1.8/gems目录下。在/home/work/oem/ruby/bin目录中可看到rake,rails等命令。
1. 老服务器数据库的备份
mysqldump -uroot redmine >/home/work/redmine/public/redmine.sql
#将数据备份在redmine.sql中
2. 线上数据导入
将redmine.sql下载到本地的/home/work/sql文件夹中;
mysql –uroot #登录数据库
mysql> create schema `redmine` default character set utf8; #创建数据库
mysql> create schema `redmine_development ` default character setutf8; #创建数据库
mysql> use redmine;
mysql> source /home/work/sql/redmine.sql;
mysql> use redmine_development;
mysql> source /home/work/sql/redmine.sql;
将老服务器的代码拷贝的新服务器的/home/work/redmine目录下;
修改 /home/work/redmine/config/database.yml文件,将相关位置的值修改为:
production:
adapter: mysql
database: redmine
host: localhost
username: root
password:
encoding: utf8
development:
adapter: mysql
database: redmine_development
host: localhost
username: root
password:
encoding: utf8
至此,可启动redmine服务,命令如下:
cd /home/work/oem/redmine
ruby script/server mongrel –e production
此时,可以通过http://机器名:8080来访问redmine了。
crontab –e可查看当前服务器的定时任务,将其复制到新的服务器,并将相关的路径做适当的调整。
服务器的迁移除了需要部署如上的内容,还应进行如下申请:
1. 数据备份的申请;
2. 域名ip变更的申请;
3. 访问外网权限的申请;
4. UUAP验证变更的申请;
(END)