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
Change default ssh port number on Ubuntu
Login as the root user or as a user that can execute sudo commands.
#open this file for editing... vim /etc/ssh/sshd_config
Find the line that reads
Port 22
Change this to an different and an available port number…
Port 8000
Next reload ssh
/etc/init.d/ssh reload
You won’t be kicked out of your session. But if you want to open a new connection to your server you need to specify the port number for the connection.
ssh -p8000 root@yourdomain.com
Using sendmail to send mail on ubuntu box
I normally install postfix for my MTA. However, I’ve never really used sendmail so I’d decide to give it a whirl for a new application I’m working on. I don’t use it for anything but handling the mail that the application needs to send out, like new user welcome emails, password resets, etc.
apt-get install sendmail
Sendmail, unlike postfix, won’t work out of the box. Postfix will prompt you for the necessary config setup when running the install. Sendmail won’t, and therefore it’s not ‘out of the box’. You’ll have to make some modifications on your own. Nothing major but this is what I’ve found in order to get it to work, reliably and quickly. The first thing I did was add the fully qualified domain name to my /etc/hosts file
#vim /etc/hosts 127.0.0.1 www.mydomain.com
After this I added the fully qualified domain name to my apache default configuration file
#/etc/apache2/sites-available/default ServerName www.mydomain.com #vhost info etc...
Reload and restart…
/etc/init.d/apache2 force-reload /etc/init.d/sendmail restart
You can test sendmail like so
sendmail email@example.com hello from me .
This should deliver a message to you (the “.” on a new line, followed by a new line, closes the message).
Install Sphinx on Ubuntu
It’s a pretty straightforward process. Download the source and compile it. There isn’t a package for it so here are the commands.
wget http://sphinxsearch.com/downloads/sphinx-0.9.8.1.tar.gz tar xzvf sphinx-0.9.8.1.tar.gz cd sphinx-0.9.8.1/ ./configure make make install
When it’s done nothing fancy happens. You’ll need to test it out w/ an application/ the api.
Installing Feedzirra RSS Parser on Ubuntu 8
I recently watched a RailsCasts episode (http://railscasts.com/episodes/168-feed-parsing) on parsing and persisting RSS feeds using Feedzirra. It took a little setting up on Ubuntu because it relies on some libraries that aren’t included with Ubuntu > 8.
The gem will fail right off the bat
gem sources -a http://gems.github.com # if you haven't already gem install pauldix-feedzirra
Here is what I needed before I could install the gem
apt-get install libcurl3 apt-get install libxml2 libxml2-dev apt-get install libxslt1-dev
Then go ahead and
gem install pauldix-feedzirra
Here are some other useful resources
http://github.com/pauldix/feedzirra/tree/master
http://ruby.zigzo.com/2009/02/15/feedzirra-installation-errors/
Recursively Zip a Directory and Files on Linux
Short and sweet! Just remember that the finished zip filename is the first argument and the directory you wish to recursively zip comes after.
zip -r name_of_your_directory.zip name_of_your_directory


