Rails

Rails or Ruby on Rails is a web application framework.

Installation

Install dev-ruby/rails:

root #emerge --ask dev-ruby/rails

Setup

root /var/www #rails new ror
root /var/www #cd ror
root /var/www/ror #rails server

Point a web browser to http://0.0.0.0:3000. are now riding rails via WEBrick. This is only for testing, not production. WEBrick could probably be used for production if it were behind nginx or an accelerator proxy such as varnish.

Configuration

Rails is not eselect aware, this might come in handy to resolving some issues, but be aware that bundle install will blast things away.

root #eselect rails list
root #eselect rails set 1

Passenger via apache

Emerge passenger:

root #emerge --ask www-apache/passenger

Add -D PASSENGER to the APACHE2_OPTS variable in Apache's config:

FILE /etc/conf.d/apache2add -D PASSENGER to apache's config
APACHE2_OPTS="-D PASSENGER"

Passenger needs Apache to relax the rules a little bit. Edit the /etc/apache2/modules.d/30_mod_passenger.conf file and insert relaxed settings before the closing </IfDefine> tag:

FILE /etc/apache2/modules.d/30_mod_passenger.confapache 2.2
<syntaxhighlight lang="apache"><Directory />
	Options FollowSymLinks
	AllowOverride all
	Order allow,deny
	Allow from all
</Directory>
</IfDefine></syntaxhighlight>
FILE /etc/apache2/modules.d/30_mod_passenger.confapache 2.4
<syntaxhighlight lang="apache"><Directory />
	Options FollowSymLinks
	AllowOverride all
	Require all granted
</Directory>
</IfDefine></syntaxhighlight>

Backup the original Apache vhost:

root #mv /etc/apache2/vhosts.d/00_default_vhost.conf /etc/apache2/vhosts.d/00_default_vhost.conf.backup

Drop in the passenger vhost file for Apache:

FILE /etc/apache2/vhosts.d/00_default_vhost.conf
<syntaxhighlight lang="apache"><IfDefine DEFAULT_VHOST>
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
      DocumentRoot /var/www/ror/public    
#  RailsBaseURI /
  RailsEnv development
      <Directory /var/www/ror/public>
Options -MultiViews
      </Directory>
</VirtualHost>
</IfDefine></syntaxhighlight>
root #/etc/init.d/apache2 restart

Point a web browser to http://0.0.0.0 or http://127.0.0.1 or http://localhost and your riding rails via passenger now.

See also

  • Ruby - The programming language used to build Rails.

External resources

This article is issued from Gentoo. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.