Ruby on Rails: deployment Git MySQL rackspace Rails ruby ruby enterprise edition ubuntu
by bseanvt
2 comments
Installing Ruby on Rails 3, MySQL, Git, Ruby Enterprise Edition, Passenger (Mod_Rails) on Ubuntu with Rackspace Cloud.
Short and sweet. Here all the commands I run in this order to set up a brand new box. It usually takes about 10 – 15 minutes on a 256 MB RAM instance. Compiling Ruby Enterprise Edition, which is super easy, will take the most amount of time. It will seem to have gotten stuck. It hasn’t. It just takes a little while.
# Update, upgrade and install all necessary packages for Ruby on Rails server if you've got a fresh Ubuntu slice apt-get update apt-get upgrade apt-get install build-essential patch libssl-dev libreadline5-dev apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby imagemagick librmagick-ruby1.8 librmagick-ruby-doc libfreetype6-dev xml-core postfix # postfix will prompt you for details # use Internet Site and enter in the domain name you are planning on sending email from apt-get install apache2 apache2-prefork-dev libapr1-dev libaprutil1-dev libcurl4-openssl-dev git-core mysql-server mysql-client libmysqlclient15-dev libmysql-ruby # mysql will also prompt you to set up a root user account. set the password to be anything you like # next, download the latest release of ruby enterprise edition but when you're installing it on your own machine version numbers and release dates may have changed. # pay attention to the version and release date before the file extension. it will be something like # ... 1.8.7-2010.02 # this will change to something like 2011.03, 2011.04... etc in the future. # just double check the paths on when you are installing and make the necessary substitutions # ruby enterprise edition is available at http://www.rubyenterpriseedition.com/download.html wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz tar xzvf ruby-enterprise-1.8.7-2010.02.tar.gz ./ruby-enterprise-1.8.7-2010.02/installer # this may take a little while (just follow the instructions) # and hit enter to install in default location (recommended) when prompted # and to install passenger (which is mod_rails for apache) /opt/ruby-enterprise-1.8.7-2010.02/bin/passenger-install-apache2-module # i take the output from the above script and add it to my available modules directory vim /etc/apache2/mods-available/passenger.conf # and enter something like this in the newly created file (your version numbers will prob. be different) LoadModule passenger_module /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/apache2/mod_passenger.so PassengerRoot /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-3.0.2 PassengerRuby /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby # and then sym link it to the enabled directory so that apache knows about it ln -s /etc/apache2/mods-available/passenger.conf /etc/apache2/mods-enabled/passenger.conf # and now i want to include ruby enterprise edition in my path so i add it to my profile (again make sure the path is correct) vim /etc/profile.d/passenger.sh export PATH=/opt/ruby-enterprise-1.8.7-2010.02/bin:$PATH . /etc/profile.d/passenger.sh # the "." file will make the setting available for the current terminal session rails -v ruby -v rake -v # should all be working now # and which ruby # should point to the ruby enterprise edition under /opt # next i # set up public/private keys # so i can do # ssh localhost without using a password cd test -e ~/.ssh/id_dsa.pub || ssh-keygen -t dsa cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys2 # and finally install git apt-get install git-core
You should now have a server ready to server ruby on rails applications!
Linux ruby Ruby on Rails: console irb Linux passenger production Rails ruby enterprise edition rubygems ubuntu
by bseanvt
leave a comment
Ruby Enterprise Edition and Passenger ./script/console production fails and instead returns Loading production environment (Rails 2.3.5) Rails requires RubyGems >= 1.3.2. Please install RubyGems and try again: http://rubygems.rubyforge.org
After installing Ruby Enterprise Edition, REE, and Passenger on Ubuntu you may see this error message when you run script/console for the first time
./script/console production # => Loading production environment (Rails 2.3.5) Rails requires RubyGems >= 1.3.2. Please install RubyGems and try again: http://rubygems.rubyforge.org
You then scratch your head and run
which gem which ruby which rails
to find that all appears to be in order. You have rubygems installed , ruby is installed and so is rails. You also find that each are pointing to the correct location, which is something like /usr/bin/gem -> /opt/ruby-enterprise-x.x.x.x/bin/gem, where x.x.x.x is the version of REE.
The problem isn’t however, with any of the above. The issue is with the location of irb. If you installed (like me) irb with apt-get install irb, then irb isn’t aware of your shiny new REE and ruby gems. It’s a simple fix however, unlink irb and symlink the /usr/bin/irb to REE’s irb like so…
rm /usr/bin/irb
And symlink it to the irb that REE has in bin
ln -s /opt/ruby-enterprise-x.x.x.x/bin/irb /usr/bin/irb
Now cd into your rails app and run
./script/console production
Ruby on Rails: 404 apache htaccess passenger phusion redmine ruby enterprise edition troubleshooting
by bseanvt
leave a comment
Installing RedMine PM Software on Apache with Phusion and REE and Seeing a 404 Page Not Found Error on Installation
If you follow the instructions on how to install the Rails Redmine PM Software (available here) and are using Apache with Passenger (REE), you need to delete the .htaccess file that is kept in RAILS_ROOT/public directory. Otherwise you’ll see a 404 page not found error. Took me a while to hunt this down. I stopped thinking about .htaccess in Rails apps but I guess REE+Passenger isn’t the default deployment yet.
Ruby on Rails: alias apache feedzirra installation mod rails passenger passenger app root path prefix php phussion ree relative url rails routing ruby enterprise edition subdirectory VirtualHost Wordpress
by bseanvt
2 comments
Install and Serve a Rails Application from PHP Subdirectory Using Apache, Phussion Passenger and Ruby Enterprise Edition
Here is how to install a Rails application out of a subdirectory (rather than as a subdomain) with the Apache web server(Apache2). In this example I’m going to use my own blog which is a WordPress installation and serve a Rails application from the subdirectory “reader”. Note, I’m not going to keep my Rails application in the document root of my WordPress Blog, which is a PHP application and therefore anyone could browse the ruby source code :(. I’ll keep it elsewhere on the filesystem and tell Apache about the location in the VirtualHost file.
You can visit the application by going to http://seanbehan.com/reader. The application just parses a bunch of RSS feeds and displays them.
It uses the Feedzirra library, which I’ve also written about http://seanbehan.com/ruby-on-rails/installing-feedzirra-rss-parser-on-ubuntu-8/.
I’m using Phussion Passenger and Ruby Enterprise Edition from the folks at Mod Rails. Installing both Phussion Passenger and Ruby Enterprise Edition is simple and a very well documented process. However, you’ll need to download and compile them from source. If you install Ruby Enterprise Edition (REE) it comes w/ Passenger so you won’t need to download it separately. I recommend going with REE. http://www.rubyenterpriseedition.com/download.html
Installing Ruby Enterprise Edition
Here are the commands to download and install (change the X.X.X to the package you’ve actually downloaded).
wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz tar xzvf ruby-enterprise-X.X.X.tar.gz ./ruby-enterprise-X.X.X/installer
When you run the installer you’ll be prompted for an installation location. Just hit enter to install in the default location. Follow the instructions from there and remember to copy/paste any code that they give you.
Official Instructions on installation for Passenger on its own are available here http://www.modrails.com/install.html I’ve written about setting up an entire box w/ Passenger here http://seanbehan.com/ruby-on-rails/new-ubuntu-slice-apache-mysql-php-ruby-on-rails-git-and/ If you already have Passenger installed and want to use REE just download and install REE and it’ll recompile Passenger with REE support if you follow the instructions.
*** If you install REE you’ll need to either link or reinstall all your gems. I linked the REE gem with the one in /usr/bin so that I can run gem install
ln -s /opt/ruby-enterprise-X.X.X/bin/gem /usr/bin/gem
The VirtualHost
If you have Passenger and REE successfully installed you’ll need to modify your VirtualHost file and add Rails application information to it.
<VirtualHost *>
# Normal virtual host info
ServerName seanbehan.com
ServerAlias *.seanbehan.com
DocumentRoot /var/www/seanbehan.com/wordpress
# Rails info goes here
Alias /reader /var/www/seanbehan.com/reader/public
<Location /reader>
PassengerAppRoot /var/www/seanbehan.com/reader
RailsEnv production
</Location>
</VirtualHost>
The “Location” directive tells apache to forward requests starting with /reader to the directory
/var/www/seanbehan.com/reader/public which is the location of our Rails app. However, we need to add the PassengerAppRoot assignment so that it knows where the actual application lives.
Routing in Rails with Relative Path
And finally, your Rails application will need to be aware of the relative url prefix assigned to each route. Normally, you could do this w/ the :path_prefix at the individual route level like so
map.resources :feeds, :path_prefix => "reader"
This will work but you can add a line to your RAILS_ROOT/config/environments/production.rb file which will handle all your routes for you. This way you don’t need to setup a relative path on your development environment work.
# in RAILS_ROOT/config/environments/production.rb config.action_controller.relative_url_root = '/reader'
Final Thoughts
Remember Ruby Enterprise Edition is the new Ruby Interpreter that your Rails web applications are using. If you
have any gem or rake issues make sure that you’re using the same interpreter that REE is using. Look in the location
installation of REE “/opt/ruby-ent…” bin/gem or bin/rake and see if that helps. I just linked those to the standard /usr/bin/gem and /usr/bin/rake and everything worked fine.
Also I’ve read some people have trouble using the alias with passenger. This may be an older issue but works for me without a problem on Ubuntu (latest).
Here are some useful resources I found along the way…
http://robots.thoughtbot.com/post/159806388/phusion-passenger-with-a-prefix
http://www.modrails.com/documentation/Users%20guide.html#deploying_rails_to_sub_uri
http://www.modrails.com/documentation/Users%20guide.html#RailsBaseURI
http://stackoverflow.com/questions/848258/server-prefix-and-rails-routes


