|
1 安装mysql 下载mysql-5.0.51b.tar.gz到目录/home/oemplat/下,新建mysql安装后的目录/home/oemplat/mysql/ 解压文件并安装配置的命令如下: cd /home/oemplat/ tar -xzvf mysql-5.0.51b.tar.gz cd /home/oemplat/mysql-5.0.51b#进入解压后的源码目录 ./configure--prefix=/home/oemplat/mysql/ --with-charset=gbk–with-extra-charsets=gbk,utf8,ascli,big5,latin1,binary--with-unix-socket-path=/home/oemplat/mysql/mysql.sock--with-mysqld-user=mysql #配置 make #编译 make install #安装 cd/home/oemplat/mysql && mkdir data #创建data目录用于存放数据库 cd /home/oemplat/mysql/bin ./mysql_install_db--user=mysql --basedir=/home/oemplat/mysql--datadir=/home/oemplat/mysql/data#初始化数据库 cp/home/oemplat/mysql/share/mysql/my-medium.cnf /home/oemplat/mysql/my.cnf#配置文件 cd/home/oemplat/mysql && vim my.cnf #修改配置文件。主要是port,socket,等。这一步以后可以直接拷贝已设置好的my.cnf /home/oemplat/mysql/bin/mysqld_safe–defaults-file=/home/oemplat/mysql/my.cnf& #启动mysql后台运行并指定配置文件
2 安装ruby 下载ruby-1.8.7-p302.tar.gz到目录/home/oemplat/下,新建ruby安装后的目录/home/oemplat/ruby 解压文件并安装配置的命令如下: cd /home/oemplat/ tar –xzvf ruby-1.8.7-p302.tar.gz cd ruby-1.8.7-p302 ./configure --prefix=/home/oemplat/ruby make make install
安装完成后建议把ruby加入到系统路径中去,这样就可以直接使用ruby命令了,方法如下: cd /home/oemplat/ &&vim ./.bashrc #编辑bashrc文件 #在bashrc文件中加入以下语句 exportPATH=/home/oemplat/ruby/bin:$PATH
3 安装rubygem rubygems是ruby的在线包管理工具,用来安装rails所需的各种组件。 下载rubygems-1.3.5.zip到目录/home/oemplat/下,解压文件并安装的命令如下: cd /home/oemplat unziprubygems-1.3.5.zip cdrubygems-1.3.5 ruby setup.rb
4 安装rails rails安装需要很多附加组件,由于测试机没有联网,所以我们需要把相关的组件下载后在本地安装。 我们安装的rails版本为2.2.3,与之对应的相关组件为: Gems1.3.5 //已经在上一步安装了 Rake 0.8.7 Activesupport 2.2.3 Activerecord2.2.3 Actionmailser2.2.3 Actionresource2.2.3
将这些组件拷到/home/oemplat/rails/目录下,依次的安装顺序和命令为: cd /home/oemplat/rails/ gem installrake geminstall -l activesupport-2.2.3.gem #-l参数表示本地安装 gem install -l activerecord-2.2.3.gem gem install -l actionpack -2.2.3.gem gem install -l actionmailer-2.2.3.gem gem install -l actionresource-2.2.3.gem geminstall -l rails-2.2.3.gem #安装完所有依赖项后,安装rails geminstall -l i18n-0.4.2.gem #装完rails后要安装这个组件
安装完成后,会在/home/oemplat/ruby/lib/ruby/gems/1.8/gems目录中看到相关的gem安装后的文件。在/home/oemplat/ruby/bin目录中也会看到rake,rails等命令。
5 安装redmine 将redmine_demo这个文件夹放在/home/oemplat/下,再修改一些配置就ok了。 修改/home/oemplat/redmine_demo/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已经安装完成,用redmine自带的webrick服务器就能提供网页服务了。 为了启动redmine,我们还需要做一些初始化的工作,如导入数据库,设置工作环境等,具体步骤如下: 1. 导入数据库到mysql 从上面对database.yml的配置中可以看出,在production和development情况下使用的数据库分别是redmine 和redmine_development,所以要在mysql数据库中建立这两个数据库。下面仅以production为例进行介绍,development的配置类似。 cd /home/oemplat/mysql ./bin/mysql -uroot -S ./mysql.sock #登录数据库 mysql> createdatabase redmine; #创建redmine数据库 mysql>source/home/oemplat/redmine.sql # 将redmine数据库导入,其中redmine.sql为事先导出的redmine数据库,存放在/home/oemplat目录下 2.设置redmine环境 上一步已经将redmine数据库导入到了mysql中,这一步将把这个数据库migrate进redmine工程中,并设置工作环境。 cd /home/oemplat/redmine_demo #进入redmine工程目录 rake db:migrateRAILS_ENV=”production” #migrate数据库 rakeredmine:load_default_data RAILS_ENV=”production” #加载默认数据,即设置环境 执行这一句后会要求你选在默认语言,选择zh即可。 3. 启动redmine服务 经过1和2的初始化配置之后,就能使用redmine自带的webrick服务器启动redmine服务了。 cd /home/oemplat/redmine_demo #进入redmine工程目录 rubyscript/server webrick –e production –p 8000 #启动服务,production环境,端口8000
在浏览器中输入http://测试机ip地址:8000就能访问到redmine了。 因为webrick速度太慢,所以要安装mongrel和apache来替代webrick进行服务。
6 安装mongrel 下载安装mongel所需组件到/home/oemplat/mongrel目录中。所需用到的组件为: gem_plugin-0.2.3.gem cgi_multipart_eof_fix-2.5.0.gem daemons-1.1.4.gem rack-1.0.1.gem mongrel-1.1.5.gem 依次安装这几个组件(上面列出的安装顺序可能有不对的地方,如果安装不上,根据错误提示改变安装顺序即可),使用的命令仍然是 gem install -l xxxxxx.gem
7 安装apache 下载httpd-2.2.19.tar.gz到目录/home/oemplat/下,新建apache安装后的目录/home/oemplat/apache/ 解压文件并安装配置的命令如下: 7.1 解压文件 tar–xzvf httpd-2.2.19.tar.gz 7.2 安装apr &apr-util 7.2.1 编译安装apr cd /home/oemplat/httpd-2.2.19/srclib/apr ./configure --prefix=/home/oemplat/apache/apr make make install 7.2.2 编译安装apr-util cd /home/oemplat/httpd-2.2.19/srclib/apr-util ./configure--prefix=/home/oemplat/apache/apr-util--with-apr=/home/oemplat/apache/apr 7.3 更改apache源代码 在路径/home/oemplat/httpd-2.2.19/server/mpm/worker下执行命令vim./worker.c 找到下面几行,并改成如下的数值,其目的是在源码中修改apache可支持的最大线程数和最大客户端数目。 # defineDEFAULT_SERVER_LIMIT 256 # defineMAX_SERVER_LIMIT 40000 # defineDEFAULT_THREAD_LIMIT 256 # defineMAX_THREAD_LIMIT 40000 7.4 编译安装apache cd/home/oemplat/httpd-2.2.19#进入源码目录 ./configure--prefix=/home/oemplat/apache/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/oemplat/apache/apr--with-apr-util=/home/oemplat/apache/apr-util/ #配置 make make install 7.5 更改apache配置 主要是修改apache监听端口,设置支持cgi,设置针对mongrel的balance轮询机制。这一步可以复制已经修改好的httpd.conf。其中具体的修改为: cd /home/oemplat/apache/apache/conf vimhttpd.conf
Listen 80 改为 Listen8080 //修改监听端口 OptionsIndexesFollowSymLinks 去掉注释后改为 Options Includes ExecCGI FollowSymLinks AddHandlercgi-script.cgi去掉注释后改为 AddHandler cgi-script .cgi .pl 在文件末尾添加 ProxyRequestsOff <Proxybalancer://myCluster> #设置针对mongrel的轮询 BalancerMemberhttp://127.0.0.1:8011 BalancerMemberhttp://127.0.0.1:8012 #BalancerMemberhttp://127.0.0.1:8013 #BalancerMemberhttp://127.0.0.1:8014 #BalancerMemberhttp://127.0.0.1:8015 </Proxy>
<VirtualHost*:8080> ServerNameoem.mi.baidu.com DocumentRoot/home/oemplat/redmine_demo/public/ ProxyPass/image ! ProxyPass/stylesheets ! ProxyPass/javascripts ! ProxyPass/ balancer://myCluster/ ProxyPassReverse/ balancer://myCluster/ ProxyPreserveHoston <Directory"/home/oemplat/redmine_demo/public/"> #添加redmine的cgi支持 OptionsIndexes ExecCGI FollowSymLinks Orderallow,deny Allowfrom all AllowOverrideall </Directory> </VirtualHost>
为了正常工作,还需要对redmine的配置做一些修改。修改redmine_demo/public中的dispatch.cgi,主要是修改ruby路径,可以参考现在已经设置好的dispatch.cgi。
从上面的配置中可以看到,apache在mongrel的8011和8012端口上设置了负载均衡,所以应该在这两个端口上开启mongrel服务 /home/oemplat/redmine_demo/script/servermongrel–e production –p 8011 /home/oemplat/redmine_demo/script/servermongrel–e production –p 8012
至此,在浏览器中输入http://测试机ip地址:8080就可以访问redmine了。
|