首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

Rails Deployment(一)modrails

2012-08-15 
Rails Deployment(1)modrailsRails Deployment(1)modrails1. Install Passengersudo gem install passeng

Rails Deployment(1)modrails
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

热点排行