Rails Quickstart
From Apis Networks Wiki
Preface
The quickstart guide uses an example application name of myapp, which will be installed under /var/www/. Further, the application will be accessed via http://rails.mydomain.com/. rails is a subdomain created via Add Subdomain assigned to /var/www/rails/. Comments which should be omitted from the terminal are prefixed at the beginning of the line with #.
Guide
1. Login to apnscp esprit and visit Language Options under Goodies to install Ruby bindings and Ruby on Rails. The latest gem versions available from RubyForge are installed. You may revisit Language Options at a later date to upgrade Ruby, Rails, and the core gems.
2. Login to the SSH with the same login credentials used for e-mail/FTP access, i.e. user@domain. If using the ssh binary, then the command ssh user@domain is not correct. ssh -l user@domain domain is.
3. Setup the Rails application from the shell.
Note: it is important that if the Rails application resides in the same directory as the document root's directory, that you do not use the same name as the directory of the document root (e.g. naming an application html in /var/www/html/ would be problematic)
cd /var/www/ rails myapp cd myapp/ chmod 755 public/ public/dispatch.fcgi # Fcgi also needs to write to log/ and tmp/, so make sure it can: chmod -R 775 log/ chmod -R 775 tmp/ vi public/.htaccess
4. You will be in Vim, a text editor. Masochists may replace vi with ed, while simpletons may use nano in place. Scroll down to the empty line above the first RewriteRule. Hit the insert key and add: RewriteBase /. Hit escape to return to normal mode, move down to change RewriteRule ^(.*)$ dispatch.cgi [QSA,L] to RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]. Save your changes and exit Vim by typing escape followed by the sequence :wq
RewriteEngine On RewriteBase / RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]5. Next, delete the directory that will act as the document root for your Rails application. Rails' public dispatch directory,
public/, will serve as the new document root. A symbolic link is necessary to redirect the filesystem from /var/www/rails/ to /var/www/myapp/public/. If you ignored the warning above, then you would need to access the URL as http://rails.mydomain.com/public/. cd /var/www/ rm -rf /var/www/rails/ ln -s myapp/public/ rails
6. Access http://rails.mydomain.com/. You should see the Rails placeholder page. Now it is time to setup your routes and write some efficient, portable, non-crashing code.
