Rails Deployment(1)modrails

本文详细介绍了如何使用Passenger在Apache上部署Ruby on Rails应用,包括安装所需软件、配置Apache及解决常见错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Rails Deployment(1)modrails

1. Install Passenger
>sudo gem install passenger

>sudo passenger-install-apache2-module

This is the console output of the command:
checking for required software...
GNU C++ compiler... found at /usr/bin/g++
Curl development headers with SSL support... not found
OpenSSL development headers ... not found
Zlib development headers ... found
Ruby development headers...found
OpenSSL support for Ruby...found
RubyGems... found
rake... found at /usr/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

I need to install all the related softwares.

>sudo apt-get install libcurl4-openssl-dev or >sudo apt-get install libcurl4-gnutls-dev
>sudo apt-get install libssl-dev
>sudo apt-get install apache2-prefork-dev
>sudo apt-get install libapr1-dev
>sudo apt-get install libaprutil1-dev

For the standalone version, we can use this command:
>cd /home/luohua/work/projectname/
>passenger start

That is ok, we can visit http://localhost:3000 to test the websites now.

2. Configure and run with apache2
And we can also put the server on apache together.
Please edit the apache configuration file:

>vi httpd.conf

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.8/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.8
PassengerRuby /usr/bin/ruby1.8

Deploying a Ruby on Rails application: an example

Suppose the rails application in /somewhere.
Add a virtual host to my apache configuration file and set its DocumentRoot
to /somewhere/public:

>cd /etc/apache2/sites-available
>vi projectname

<VirtualHost *:81>
ServerName www.yourhost.com
DocumentRoot /somewhere/public #be sure to point to public
<Directory /somewhere/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>

>cd /etc/apache2/sites-enabled
>ln -s ../sites-available/projectname

when I visit the URL http://localhost:81, I got these error messages:
syntax error, unexpected ':', expecting '}' format.json { render json: @accounts }

After I change the syntax from render json: @accounts to render json => @accounts. That is fine then.

references:
http://www.modrails.com/install.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值