My Kubuntu machine which I prefer to use for Rails development was getting pretty crochety. I had started out on 7.04, did a distribution upgrade to 8.04, ran into some major problems installing DropBox (LinuxFormat Magazine helped me fix this problem). Finally, I tried a distribution upgrade to 9.10 and it was barely limping along. Several folks suggested a clean install from scratch, so I decided to go with Kubuntu, 10.04, 64-bit. Here's how I went about it.
Prior to the installation, I took a tar backup of my system and also did a copy (cp -a ...) to an external USB drive. Be careful with cp: if you have other media attached (like another network-attached drive I had a /media/wdhd1), the command "cp -a / /
BTW, I really like the NDAS combo drives: eSata, Network-Direct Attached, USB. Reasonably-priced and very effective.
- First get Kubuntu (or whatever flavor of Linux distro you want). I went to the Kubuntu site at http://www.kubuntu.org/getkubuntu where you can either download directly or get a CD/DVD. I downloaded the 64-bit desktop version here: http://www.kubuntu.org/getkubuntu/download#download-block
- Install kubuntu - pretty straight-forward.
- Make sure that your machine will boot from a CD
- Insert CD, reboot, follow the instructions.
- A true linux sysadmin might have gotten fancy with the disk partitioning, but I just went with the default which was everything in a single partition. It’s not like this is a heavily-loaded server...right?
- There were a number of prompts for keeping or replacing existing files (such as mysql/mycnt, /etc/apcupsd/apcupsd.conf, /etc/cups/cupsd.conf, etc...) and I just took the default since I had copies of all my previous config files.
- At one point, my mouse went inactive (I connect it through a KVM switch) but that cleared up pretty quickly.
- Install your favorite browser by using Kubuntu’s built-in Konqueror browser. I chose Chrome -- I’ve been using Firefox for years, but in the past, I’ve run into problems with Firefox on Linux: older versions, conflicts when trying to upgrade... I still use FireFox on Windows/Mac, but Chrome is my preferred browser for Linux.
- The Ubuntu community has a very good site on how to do the Rails install: https://help.ubuntu.com/community/RubyOnRails
- Make sure you DO NOT do “sudo apt-get install rails”. This gives you an old version and you can’t track your gems easily. If you mistakenly do that, simply type “sudo apt-get remove rails” and go back to the above link
- REMEMBER to add the new ruby gems path to your path so that your system can find the stuff you just installed (this is in the . The command is:
You’ll have to add this to your .bashrc file so that it will always be done when you start up.
- BTW, I add the following two aliases to my .bashrc so that I can quickly and easily edit .bashrc and update my environment for any new values
- alias brcs='source /home/jseidel/.bashrc'
- alias brcvi='vi /home/jseidel/.bashrc'
- The ‘brcvi’ alias drops me into vi (replace with your preferred editor) so that I can make changes. Notice that it always points to my home directory so that I can do this regardless of where I am.
- the ‘brcs’ alias “sources” the current/updated .bashrc file. I.e., it “Reads and executes commands from .bashrc in the current shell environment”, with the result that the changes you made are reflected in your current bash environment. So to add a new alias, I create the alias in my current bash, test it out, then brcvi to add it to my .bashrc and then brcs to make it active and then test to make sure I didn’ have a typo.
- Install git -- you are using git, aren’t you? GitHub has a great tutorial on how to do this. Just go to: http://help.github.com/linux-git-installation/ and follow the instructions. There's also an excellent book, Pro Git, by Scott Chacon, that is available on line at http://progit.org/book/.
- Once you’ve installed git, you have to generate an SSH keypair (see http://en.wikipedia.org/wiki/Secure_Shell if you want to learn more about SSH and http://en.wikipedia.org/wiki/Public-key_cryptography if you want to learn more about keypairs) so that you can speak encrypted git. GitHub has another excellent tutorial on how to do this; see http://help.github.com/linux-key-setup/. Just follow the instructions there and you should have no problem. I did install the xclip utility -- makes it easy to copy/paste the information into github.
- If you don’t want to key-in your SSH passphrase everytime you use it, GitHub has help here as well. Go to http://help.github.com/working-with-key-passphrases/ and about half-way down the page there’s a section on “autolaunching ssh-agent” when you start your machine so that you only have to enter the passphrase once when you boot your machine.
- Turns out I had some permissions problem in my .ssh directory: I kept getting
“Bad owner or permissions on /home/jseidel/.ssh/config”
when testing things with “ssh firstname.lastname@example.org”. Well, GitHub was there again, with their trouble-shooting page at http://help.github.com/troubleshooting-ssh/. Towards the bottom of the page in the “SSH Config” section, the two ‘chmod’ commands did the trick for me.
chmod 700 ~/.ssh chmod 600 ~/.ssh/*
- And don’t forget to setup your git config options -- at least these two
git config --global user.name "your name"
git config --global user.email email@example.com
- I use RubyMine (http://www.jetbrains.com/ruby/download/index.html#linux for a 30-day free trial) so that was the next thing to install. Replace this section with whatever IDE you prefer: Aptana, NetBeans, ...
- To run RubyMine, you have to have the Sun Java (JDK 1.6). I found that at http://www.oracle.com/technetwork/java/javase/downloads/index.html and followed the instructions. It turned out to be completely straight-forward.
- Now you’ve got everything ready to do; let’s create your first rails app in your shiny new Linux development machine:
git commit -m "Empty Rails application"
- Now create your github repository -- GitHub has the answer again: http://help.github.com/creating-a-repo/
- Once this is done, copy in the repository URL
- Back to bash and hooking up your new repository with your new rails app
- Tell your local git repository about the github repository:
git branch add origin
- Push your MyApp rails application up to github:
git push origin master