Screencast: Setting up — Linux
Agenda
Most students using Linux in this course are using Ubuntu, so that’s what I’m going to demo: Ruby/Rails setup on Ubuntu. There were a number of RedHat/Fedora people: try rpm instead of aptitude; it should be very similar. For SuSE, use yast. If you get in a real jam, send me some e-mail. I might possibly do an additional screencast for RedHat/Fedora, and I would gladly welcome a student-made screencast, if you can figure out how to do it.
One thing I mention below is that for Linux, you conduct some of the installation through Linux system tools (aptitude, rpm, yast, etc.) and some through the Ruby “gem” mechanism. One mildly confusion bit is that the MySQL database is installed with the Linux system tool, but the MySQL gem, which provides better performance, happens through gem. It is possible to install Rails itself through the Linux system tools, but it will usually be an older version. In short, make sure you’re using the right tool for the right component.
I have a bunch of Linux systems set up, but I don’t know how to record a screencast on them, and also I don’t think I should destabilize them since they’re all set up just right. So what I’m going to do is set up Linux on a virtual machine running under Windows, and I’ll make a screencast of that.
NOTE: My office building is closed this weekend, so I won’t be able to use my regular screencast software and headset. This means that the volume may be low, and the mouse-tracking won’t be as good. I think this is pretty straightforward, so the visual data should be enough.
Here’s what happens the screencast:
- Download and install the VMWare Player (I’ll only show the result of this…). This is free software that can run WMWare virtual machines. There are versions for Windows and for Linux. Also, the VM should work in the new Mac Fusion product from VMWare, which you can download and test for 30 days. The VMWare Player comes from here: http://www.vmware.com/download/player/download.html
- Download Ubuntu 7.04 Server from http://www.thoughtpolice.co.uk/vmware/
- Start up the VMWare Player by clicking on the VM’s
.vmxfile. If you try this at home, you may get asked a question about creating an id for the VM. You do want to go ahead and select “create.” - The login credentials for the VM we’re downloading are: username: notroot password: thoughtpolice
- One reason I decided to use that site for the VM was because of the password. When I taught at Ohio State, I used to teach a semester-long course in the writings of George Orwell (who wrote Nineteen Eighty-Four). But I digresss…
- For Linux, we want to use the installer that comes with the distro for everything that isn’t installed as a gem. At the same time we’ll install the ssh server, MySQL, all the software used for building code from C, the MySQL development support stuff, as well as Firefox. Firefox depends on X-Windows, so we will get that, too. It will take some time to install all of this stuff!
- So that command is (all on one line):
sudo aptitude -r -y install ssh ruby1.8 rubygems irb ri rdoc mysql-server-5.0 build-essential libmysqlclient15-dev firefox
- You might type
time sudo aptitude ...so that you can go off for coffee and still see how long it takes. - The next step is to install the gems
gem install rails --include-dependencies gem install mongrel --include-dependencies gem install mysql --include-dependencies
- Note that the runnable code for the gems end up in
/var/lib/gems/1.8/bin, and you will need to add this to your path. So edit .bashrc and add this line at the end:
export PATH=/var/lib/gems/1.8/bin:$PATH - For the install verification, you need to check the versions for the installed code; you also need to grab a screenshot that shows what happens after you go to the default Rails web page and click on the link to see your setup. For this to work, you have to run the browser locally. This will be easy on your own computer, but for my setup, it will require me to use X-Windows to actually run Firefox on the virtual machine. Watch the video for this. As I say, for you it’s easy, for me there are extra steps.
- NOTE: At the end of the first screencast, you see me picking which version of the mysql gem to install. The video ends with me picking 2, but actually 3 was right: I was being fumble-fingered and the video ran out before it caught me doing the right thing.
View (you will want to maximize your browser; to go “full-screen” in Firefox, press F11; then to turn off full-screen, press F11 again)
September 23rd, 2007 at 5:17 pm
Hi John,
I’m in the middle of installing RoR on my Ubuntu linux machine. I issued the
“gem install rails –include-dependencies”
command about 45 minutes ago, and the disk is still thrashing after displaying the line
“Bulk updating Gem source index for: http://gems.rubyforge.org”
I realize that rails may be a fairly large install, so I’m not sure whether I should quit the process and try again. Should this be taking this long?
Thanks,
Eric
September 23rd, 2007 at 5:58 pm
Are you seeing any output to the console? The really time-consuming stuff is at the end, when it is installing documentation for ri and rdoc. That can definitely take awhile, but you should be seeing an occasional line that tells you something is happening.
The *entire* gem install rails process could well take 45 minutes if you have a slow disk and/or slow network latency.
September 23rd, 2007 at 6:05 pm
Hi John,
I’m guessing you’re right about the slow disk and latency: I’m running ubuntu on top of an Pentium III. It may be time for a system upgrade. Excellent screencast, by the way.
Thanks,
Eric
September 23rd, 2007 at 9:05 pm
Hi John
I thought this would be helpful for other students who use Redhat/Fedora distros.
This installation is for fedora 7, but may work with redhat / Centos distros too.
I used yum (like apt-get ) to install various packages.
1. yum groupinstall ‘Development Tools’
## installed various development tools including gcc compilers.
## (if you are concerned about diskspace, install only what is necessary)
2. yum install ruby rubygems rdoc mysql-server ruby-devel mysql-devel
## main ruby and mysql packages
3. gem install mongrel –include-dependencies
4. gem install rails –include-dependencies
5. gem install mysql — –with-mysql-config
Here is the output
——————-
[root@localhost ~]# ruby -v
ruby 1.8.6 (2007-06-07 patchlevel 36) [i386-linux]
[root@localhost ~]# gem -v
0.9.2
[root@localhost ~]# mongrel_rails –version
Mongrel Web Server 1.0.1
[root@localhost ~]# rails -v
Rails 1.2.3
[root@localhost ~]# irb -v
irb 0.9.5(05/04/13)
[root@localhost ~]# mysql -V
mysql Ver 14.12 Distrib 5.0.37, for redhat-linux-gnu (i686) using readline 5.0
[root@localhost ~]# gem list mysql
*** LOCAL GEMS ***
mysql (2.7)
MySQL/Ruby provides the same functions for Ruby programs that the
MySQL C API provides for C programs.
I also made a screencast of the installation in .ogg and .avi formats. I uploaded it to Google videos, but the quality if very poor.
Let me know if you would like to get a copy of it. (15 MB)
Hope this helps!
Joseph
September 23rd, 2007 at 10:01 pm
What does the straight .avi look like (i.e., before getting to Google Video)?
If you can save the screencast in .swf (flash/shockwave…)
September 23rd, 2007 at 10:21 pm
Is anyone else getting this?
root@jacob-desktop:/usr/src/rubygems-0.9.4# gem install rails –include-dependencies
Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR: While executing gem … (Gem::GemNotFoundException)
Could not find rails (> 0) in any repository
September 23rd, 2007 at 11:17 pm
Jacob — That doesn’t look good.
How did you install gem? I see that you’re in the src/ directory: gem should be in your path, so you should be able to run it from anywhere.
Also:
What do you get when you type:
gem env
(this dumps the gem “environment,” and will show where gem thinks the repository lives, where gems are supposed to end up, etc.
September 24th, 2007 at 7:00 am
jacob@jacob-desktop:~$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
jacob@jacob-desktop:~$ irb -v
irb 0.9.5(05/04/13)
jacob@jacob-desktop:~$ gem -v
0.9.4
jacob@jacob-desktop:~$ gem env
RubyGems Environment:
- VERSION: 0.9.4 (0.9.4)
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- GEM PATH:
- /usr/local/lib/ruby/gems/1.8
- REMOTE SOURCES:
- http://gems.rubyforge.org
Btw, I compiled ruby 1.8.6 on my own box (Xubuntu 6.06 Dapper Drake), because I noticed that the aptitude dapper universe only has 1.8.2, and you said the class should use 1.8.5 or higher. There were some hurdles along the way to compiling my ruby, but I had fun with the challenge. It’s actually my first attempt at building anything in Linux. I used this method:
http://www.carmelyne.com/2007/7/17/compiling-ruby-1-8-6-on-ubuntu
There was also a bit of a challenge with the gem installation (latest version, 0.9.4). Something was wrong with the zlib package. The solution posted by this fellow seems to have worked:
http://lucaschan.com/weblog/2007/03/22/installing-ruby-on-rails-on-centosredhat-4x/
September 24th, 2007 at 7:36 am
The rails installer is working now. I have a hunch that the remote sources service went down last night, and somebody just woke up and restarted it.
September 24th, 2007 at 2:34 pm
Wow, scary.
October 5th, 2007 at 11:29 pm
Thank you for sharing!