Debian中ruby on rails运行环境的搭建

很久之前的笔记了,现在整理出来, 这里采用的是Apache + Mongrel Cluster, 其实shitou个人还是喜欢Lighttpd + FastCGI搭配的说,因为其他原因只能现在跑这样的环境啦- -||

软件:

ruby-1.8.7-p72.tar.gz

rubygems-1.3.0.tgz

ruby-zlib-0.6.0.tar.gz

mysql-ruby-2.8.tar.gz

安装:

安装ruby

#apt-get install gcc libc6-dev make tmake autogen automake \

build-essential indent intltool

#tar zxvf ruby-1.8.7-p72.tar.gz

#cd ruby-1.8.7-p72

##开启最后一行的zlib支持

#vi ext/Setup

#./configure --prefix=/usr/local/ruby

#make; make install

##把/usr/local/ruby/bin加入环境变量PATH中, 并写入文件/root/.profile中

#apt-get install zlib1g-dev

#cd ext/zlib

#ruby extconf.rb;

#make; make install

安装rubygems

#tar zxvf rubygems-1.3.0.tgz

#cd rubygems-1.3.0

#ruby setup.rb

安装rails

#gem install rails –version 2.0.2

支持rails console

#apt-get install libreadline5-dev

#cd ruby-1.8.7-p72/ext/readline

#ruby extconf.rb

#make; make install

在不安装SSL的话rails应用启动会报错

#apt-get install libssl-dev

#cd ruby-1.8.7-p72/ext/openssl

#ruby extconf.rb

#make; make install

安装mysql

#apt-get install mysql-server mysql-client libmysqlclient15-dev

安装ruby的mysql的C接口

#tar zxvf mysql-ruby-2.8.tar.gz

#cd mysql-ruby-2.8

#ruby extconf.rb –with-mysql-include=/usr/include/mysql –with-mysql-lib=/usr/lib

#make; make install

安装mongrel

#gem install mongrel mongrel_cluster

Apache, PHP的安装

#apt-get install apache2

#apt-get install php5 php5-mysql libapache2-mod-php5 php-pear

mongrel的配置

/railsapp/config/mongrel_cluster.yml:

cwd: /var/www/rails/cal_point

port: 3000

environment: production

group: www-data

user: www-data

address: 127.0.0.1

pid_file: log/mongrel.pid

servers: 3

Apache开启Proxy的相关模块, 配置

/etc/apache2/httpd.conf:

<Proxy balancer://myproxycluster>

#loadfactor is the weight of the server, range 1-100, the bigger the stronger

BalancerMember :3000    loadfactor=10

BalancerMember :3001    loadfactor=10

BalancerMember :3002    loadfactor=10

</Proxy>

ProxyPass / balancer://myproxycluster/

ProxyPassReverse / balancer://myproxycluster/

启动mongrel cluster:

进去rails项目的根目录:

#mongrel_rails cluster::start

注意: 启动前要保正log文件夹的权限为Apache运行用户(在debian中一般是www-data)可写的

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyfdfs.html