欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Rails Deployment(1)modrails

程序员文章站 2022-07-15 14:54:05
...
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