This post is a part of a mini-series!
Day 6
1) Installing (You Are Here)
2) Test a Rails App! link
3) Configuring Webserver link
4) Configuring MySql link
:: Installing Ruby
ref: http://ryanbigg.com/...-rails-and-you/
Install prerequisites so we can use curl and download rvm (Ruby Version Manager).
Troubleshooting (nodejs isn't in the default repository list on debian stable):
Download and install rvm (not using apt-get obviously)
Then, sort of put rvm into the environment PATH (this won't work if you used 'su', and rvm may only be available if you're logged in through SSH. You also need to log out and log back in...)
(Run the below code as the desired user and it will put stuff at the bottom of ~/.bashrc)
(Run as root and it should end up in /root/.bashrc)
Then you could try to run this command or if that doesn't work, restart your ssh session (I don't get linux...)
If your installation is successful, typing $ rvm will yield a result.
One more configuration is needed for rvm to work properly:
Now install a few versions of ruby:
Weeks later, update rvm and ruby 1.9.2 to the latest patch!
Switch to using a specific version of ruby, and set the default version to be used at login (necessary).
Sometimes you'll have instances where 1.9.2 will be incompatible with some rails thing you're trying to do. In that case, switch your ruby version down to 1.8.7.
Getting RVM working in x11(linux GUI)
:: Installing Gem and Gemsets
When we installed ruby through rvm, it automatically installed gem for us (version 1.6.2 for me). Check this site out for details on gemsets and using rvm to manage gem. https://rvm.beginres...gemsets/basics/
This rvm program is so cool that it lets us have many, compartmentalized 'gemsets' for each ruby version you have installed. Let's create an alternative gemset for ruby 1.8.7 (which we're already set to because our last version change command was rvm --default use 1.8.7
list:
Now if we really wanted to, we could install rails version 2.3.5 and test it here inside 1.8.7, while still having the latest version of rails in the head 1.9.2 version with out any confusion over which rails app will be used. Let's switch back to the main 1.9.2 version since we don't want to do anything with gems yet.
Here's an interesting trick where you put a .rvmrc file in some directory and it will automatically setup your rvm to be using the version you specified.
To update gem using rvm:
For me, it gave me a dumb warning and so I had to run the command a second time...
For a standalone installation of gem, you'd see this command, but usually you can get away with using rvm to update it for you:
You can downgrade too, if gems are giving you tons of warnings and not working:
:: Installing Rails
Apparently, if you use apt-get to install gem, the name of gem changes depending on what version it is atm... Luckily this new procedure I wrote avoids this problem.
OK, this step is weird. If you're lucky, it will work. If you're unlucky, you'll need to try it again. Don't ask me how. Just try again if it doesn't do anything for half an hour or something... My test machine sux.
Also, what if you want to install another version of rails in addition to the latest and greatest?
Easy enough.
:: More About NodeJS (required for rails 3.2 and up)
Rails is apparently asking me to install a javascript runtime. I had read about them a while ago, and it's basically a way of letting you execute javascript as though it were any other language like ruby or C++ without going through a web browser. I know, it totally weirded me out when I first heard about it because to me (due mostly to the environments I run it on) javascript is the sloppy language you use because it's the only thing available. I guess that sentiment isn't felt in the rest of the community so maybe I will look into it more.
An alternative method of installation (we already installed it up at the top, so you don't need to install it again):
ref: http://sekati.com/et...-debian-squeeze
:: Configure MySQL with rails
Since we already installed MySql in a prior entry, we just need to install the mysql adapter gems.
(When I found a reference, it said do libmysqlclient14-dev, but it was out of date by 1 I guess...)
(ref (borrowed a single command): http://daniel.lorch....nstall_debian/)
:: MAKE HELLO WORLD!!!
zomg, we did it! We can even test it out on WEBrick, the built in server!
Want to make webrick faster?
ref: http://kevin.vanzonn...n_ubuntu_lucid/
(you might need some of this still too. Some we installed previously, but w/e.)
Let's close this entry up with a hello world in ruby on the command line (this is not 'rails' it's just ruby).
(vi hello.rb)
to run that ruby script, type
You may go to the next entry on rails if you'd like.
Day 6
1) Installing (You Are Here)
2) Test a Rails App! link
3) Configuring Webserver link
4) Configuring MySql link
:: Installing Ruby
ref: http://ryanbigg.com/...-rails-and-you/
Install prerequisites so we can use curl and download rvm (Ruby Version Manager).
$ apt-get update $ apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf nodejs
Troubleshooting (nodejs isn't in the default repository list on debian stable):
Spoiler
Download and install rvm (not using apt-get obviously)
$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Then, sort of put rvm into the environment PATH (this won't work if you used 'su', and rvm may only be available if you're logged in through SSH. You also need to log out and log back in...)
(Run the below code as the desired user and it will put stuff at the bottom of ~/.bashrc)
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
(Run as root and it should end up in /root/.bashrc)
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
Then you could try to run this command or if that doesn't work, restart your ssh session (I don't get linux...)
$ . ~/.bashrc
If your installation is successful, typing $ rvm will yield a result.
One more configuration is needed for rvm to work properly:
$ rvm pkg install zlib
Now install a few versions of ruby:
$ rvm install 1.8.7 $ rvm install 1.9.2
Weeks later, update rvm and ruby 1.9.2 to the latest patch!
$ rvm get latest # this will update rvm itself $ rvm reload $ rvm install 1.9.2
Switch to using a specific version of ruby, and set the default version to be used at login (necessary).
$ rvm use 1.9.2 $ rvm --default use 1.9.2
Spoiler
Sometimes you'll have instances where 1.9.2 will be incompatible with some rails thing you're trying to do. In that case, switch your ruby version down to 1.8.7.
$ rvm --default use 1.8.7
Getting RVM working in x11(linux GUI)
Spoiler
:: Installing Gem and Gemsets
When we installed ruby through rvm, it automatically installed gem for us (version 1.6.2 for me). Check this site out for details on gemsets and using rvm to manage gem. https://rvm.beginres...gemsets/basics/
This rvm program is so cool that it lets us have many, compartmentalized 'gemsets' for each ruby version you have installed. Let's create an alternative gemset for ruby 1.8.7 (which we're already set to because our last version change command was rvm --default use 1.8.7
$ rvm gemset create testrails2.3.5 $ rvm [email protected] $ rvm gemset list
list:
$ rvm gemset list $ rvm gemset list_all
Now if we really wanted to, we could install rails version 2.3.5 and test it here inside 1.8.7, while still having the latest version of rails in the head 1.9.2 version with out any confusion over which rails app will be used. Let's switch back to the main 1.9.2 version since we don't want to do anything with gems yet.
$ rvm 1.9.2
Here's an interesting trick where you put a .rvmrc file in some directory and it will automatically setup your rvm to be using the version you specified.
$ echo "rvm 1.9.2" > APPNAME/.rvmrc
To update gem using rvm:
$ rvm rubygems 1.8.5
For me, it gave me a dumb warning and so I had to run the command a second time...
For a standalone installation of gem, you'd see this command, but usually you can get away with using rvm to update it for you:
$ gem update --system
You can downgrade too, if gems are giving you tons of warnings and not working:
$ gem update --system 1.7.2
:: Installing Rails
Apparently, if you use apt-get to install gem, the name of gem changes depending on what version it is atm... Luckily this new procedure I wrote avoids this problem.
$ gem install rails --include-dependencies INFO: `gem install -y` is now default and will be removed INFO: use --ignore-dependencies to install only the gems you list <randomly hit enter once?> <randomly hit enter again> <randomly hit enter again?> <wait a long time for it to start updating you with progress reports on its downloads...>
OK, this step is weird. If you're lucky, it will work. If you're unlucky, you'll need to try it again. Don't ask me how. Just try again if it doesn't do anything for half an hour or something... My test machine sux.
Also, what if you want to install another version of rails in addition to the latest and greatest?
$ gem install rails -v=2.3.5
Easy enough.
:: More About NodeJS (required for rails 3.2 and up)
Rails is apparently asking me to install a javascript runtime. I had read about them a while ago, and it's basically a way of letting you execute javascript as though it were any other language like ruby or C++ without going through a web browser. I know, it totally weirded me out when I first heard about it because to me (due mostly to the environments I run it on) javascript is the sloppy language you use because it's the only thing available. I guess that sentiment isn't felt in the rest of the community so maybe I will look into it more.
An alternative method of installation (we already installed it up at the top, so you don't need to install it again):
Spoiler
ref: http://sekati.com/et...-debian-squeeze
:: Configure MySQL with rails
Since we already installed MySql in a prior entry, we just need to install the mysql adapter gems.
(When I found a reference, it said do libmysqlclient14-dev, but it was out of date by 1 I guess...)
$ apt-get install libmysqlclient15-dev $ gem install mysql $ gem install mysql2 ~~that might be important too...
(ref (borrowed a single command): http://daniel.lorch....nstall_debian/)
:: MAKE HELLO WORLD!!!
$ cd /var/rails $ rails new myapp
zomg, we did it! We can even test it out on WEBrick, the built in server!
$ cd myapp $ rails server
http://localhost:3000
Want to make webrick faster?
Spoiler
ref: http://kevin.vanzonn...n_ubuntu_lucid/
(you might need some of this still too. Some we installed previously, but w/e.)
$ apt-get install -y libdbd-sqlite3-ruby sqlite3 libsqlite3-dev libsqlite3-ruby $ gem install sqlite3
Let's close this entry up with a hello world in ruby on the command line (this is not 'rails' it's just ruby).
(vi hello.rb)
# this is a super cool hello world example puts "hello world" puts "!" * 5 puts 1 puts "!" * 3
to run that ruby script, type
$ ruby hello.rb
You may go to the next entry on rails if you'd like.
0 Comments On This Entry
Trackbacks for this entry [ Trackback URL ]
← January 2022 →
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |
Tags
My Blog Links
Recent Entries
-
Git (Basic -> Intermediate): Manipulate and tidy up your commit history (git squash)
on Apr 18 2013 10:56 AM
-
-
-
-
Recent Comments
-
NotarySojac on Mar 30 2012 08:17 AM
Setting up a PXE server and booting a client (TFTP, PXE, DHCP, ...NFS...)
-
kaotikmynd on Mar 28 2012 09:30 PM
Setting up a PXE server and booting a client (TFTP, PXE, DHCP, ...NFS...)
-
NotarySojac on Mar 20 2012 07:27 AM
Setting up a PXE server and booting a client (TFTP, PXE, DHCP, ...NFS...)
-
Shane Hudson on Mar 19 2012 05:28 PM
Setting up a PXE server and booting a client (TFTP, PXE, DHCP, ...NFS...)
-
Search My Blog
9 user(s) viewing
9 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)



Leave Comment








|