Revisiting Installing Rails 3
Why take a second look
From time to time I get a few emails asking me to update my rails install articles for smaller hosting arrangements. For the most part this means that MySQL and Apache are on the same machine. I also get a few questions about why I configure things a certain way, or don’t configure other things. I figure this was be a good time to explain my choices and update the install steps a tiny bit for smaller hosts. To see the original articles take a look at Installing Rails 3 in 6 steps.
Let me state upfront that this is more of an article for developers then clients. Clients can take a look, of course, but I intend this to be more useful for developers. If you wish to have your server configured then give me call and we can work something out, but trying these steps on your own can lead to disaster if you don’t know what your doing.
The Updated Steps
sudo apt-get update sudo apt-get upgrade sudo apt-get install mysql-server-5.1 sudo apt-get install apache2 sudo apt-get install git-core ruby1.8 build-essential libssl-dev ruby rdoc irb libopenssl-ruby imagemagick libmagick9-dev ruby1.8-dev libmysqlclient15-dev apache2-prefork-dev libapr1-dev postfix libaprutil1-dev libcurl4-openssl-dev wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz tar -xzf rubygems-1.8.24.tgz ; cd rubygems-1.8.24/; sudo ruby setup.rb sudo gem1.8 install rails --no-rdoc --no-ri sudo gem1.8 install passenger --no-ri --no-rdoc
These are more or less in the order of most frequently asked.
Why do you include postfix in the install?
Sendmail on linux is not setup by default to do mailing for websites. It can be setup to do it, but it’s not as secure or easy to configure as postfix. You could switch that package out for whatever mail transfer agent you like.
Why do you use the –no-ri –no-rdoc arguments
Basically to save time, I don’t need documentation in production. If I need to look something up in production then everyone is in a lot of trouble. Better to do your looking up in development.
What is gem1.8
gem1.8 is the binary name given to the gem executable when you install it on a system that could have several versions of gem installed. Linux has a gem package and if you call your gem executable “gem” it could conflict. Thankfully ruby gems takes this into effect and it just magically installes gem1.8. It’s also important to note that gem1.8 means I am using ruby 1.8.something.
Why do you use Ruby 1.8 isn’t 1.9 newer/better?
Yes and no. For the most part 1.8 and 1.9 are directly compatible. I dev and deploy 1.8 code because it’s simply more stable. While this is constantly changing, and 1.9 will be the standard very soon, for the time being, 1.8 is just safer and more hassle free. 1.9 is just not production ready in my opinion.
Why do you install imagemagick
Imagemagick is the defacto image manipulation library. If you have a bit of code that some how modifies an image, it’s almost certainly built on imagemagick. You will need it, so best to install it now.
Why don’t you install apache or mysql, Or why didn’t you use “tasksel”?
The instructions above do install apache and mysql because a lot of people have asked for it. The original instructions did not because frankly, apache was already installed in my base server image (I use on ec2), and I really try to have mysql and apache on different servers for performance reasons. Some small and medium sites can have mysql and web on the same server, but generally I find it’s not a good idea. I figure if you need them on the same server you can just install them.
As for tasksel, I don’t like to use it because it uses to much memory. A typical install step would look like:
sudo tasksel install lamp-server
That’s fine, except there no reason a rails production server should install PHP, I don’t prefer MySQL installed on the same box. In fact I think, while that option is nice if your playing around, I have never had it save me any time on a serious production box. Every time I have used it I have had to spend way more time “configuring” the apache install for performance then if I just go with the default. I mean lets look at a standard rails server. Apache sits in front of passenger. Passenger does all the ruby work and apache just serves static content. Apache doesn’t need any mods. Mod_rewrite just causes problems, etc. Non-passenger deployments also need custom load balancer setups, and proxy setups. Heavy web sites may need load balancing as well. Tasksel just gets in the way for me. it’s a taste thing. Most sites will need mod_ssl, but thats included in the lines above and you just have to link the files from mods_available into mods_enabled, or better yet use a2enmod.
I hope that has helped everyone understand why I make the install choices I do. Keep in mind that this install happens on a box that is completely new. Older installs may need adjusted steps. Also it doesn’t hurt to adjust the instructions for more recent versions of ruby gems.
As always if you have any questions then send me an email or give me a call.
Coteyr.net Programming LLC. is about one thing. Getting your project done the way you like it. Using Agile development and management techniques, we are able to get even the most complex projects done in a short time frame and on a modest budget.
Feel free to contact me via any of the methods below. My normal hours are 10am to 10pm Eastern Standard Time. In case of emergency I am available 24/7.
Phone: (813) 421-4338