arthurln 发表于 2013-1-16 00:40:58

Debian下Ruby、Rails、Passenger安装

1、安装ruby
$ sudo aptitude install ruby ruby-dev ri rdoc irb libopenssl-ruby
如果使用sqlite3还要安装
$ sudo aptitude install sqlite3 libsqlite3-ruby libsqlite-dev libsqlite3-dev
使用mysql需要安装
$ sudo aptitude install libmysql-ruby

2、安装gem
$ sudo aptitude install rubygems
编辑~/.bashrc
$ vi ~/.bashrc
在最后添加
export PATH="$PATH":/var/lib/gems/1.8/bin
使变更立即生效
$ source ~/.bashrc

3、安装rails
$ sudo gem install rails

4、安装passenger
$ sudo gem install passenger$ sudo /var/lib/gems/1.8/bin/passenger-install-apache2-module
passenger的安装非常体贴,安装前会有检查,如果系统不符合要求会给出详细的解决方法(真希望所有的linux软件都能做成这样)。
下边是我的检查结果:
Checking for required software...* GNU C compiler... found at /usr/bin/g* Ruby development headers... found* OpenSSL support for Ruby... found* RubyGems... found* Rake... found at /var/lib/gems/1.9.0/bin/rake* Apache 2... found at /usr/sbin/apache2* Apache 2 development headers... not found* Apache Portable Runtime (APR) development headers... not found* Apache Portable Runtime Utility (APU) development headers... not found
下面是根据passenger提供的说明进行的操作(仅供参考):
$ sudo apt-get install apache2-prefork-dev libapr1-dev libaprutil1-dev
再次运行上边的passenger-install-apache2-module,安装成功后pessenger提供进一步配置说明:
Please edit your Apache configuration file, and add these lines:LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.4/ext/apache2/mod_passenger.soPassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.4PassengerRuby /usr/bin/ruby1.8...Suppose you have a Ruby on Rails application in /somewhere. Add a virtual hostto your Apache configuration file, and set its DocumentRoot to/somewhere/public, like this:<VirtualHost *:80>ServerName www.yourhost.comDocumentRoot /somewhere/public # <-- be sure to point to 'public'!</VirtualHost>

5、根据上边的说明更改apache的rails mod的配置
修改rails.load
$ sudo vi /etc/apache2/mods-available/rails.load
添加如下内容(仅供参考)
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.4/ext/apache2/mod_passenger.so
修改rails.conf
$ sudo vi /etc/apache2/mods-available/rails.conf
添加如下内容(仅供参考)
PassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.4PassengerRuby /usr/bin/ruby1.8

6、配置虚拟主机
$ sudo vi /etc/apache2/sites-available/yoursite

<VirtualHost *:80>    ServerName www.yourhost.com    DocumentRoot /somewhere/public    ...

7、使对apache的更改生效
启用模块
$ sudo a2enmod rails
启用vhost
$ sudo a2ensite yoursite
重启apache
$ sudo /etc/init.d/apache2 restart
页: [1]
查看完整版本: Debian下Ruby、Rails、Passenger安装