Tuesday, May 19, 2015

Installing Bitnami Ruby Stack as root on Ubuntu 14.04

I have installed Bitnami Ruby Stack 2.2.2-0 Dev (64bit) as root user on my XUbuntu.

In order to make its installation simple, I removed previously installed PostgresSQL, MySQL, Nginx, and Apache servers from my machine. (I did not bother removing Ruby because previously installed version in this machine was 1.9x, and it should have no conflict with Ruby 2.2.x that is to be installed with this version of Ruby Stack.)

1. Resources

2. My environment

I use a 64-bit Ubuntu 14.04 (XUbuntu) machine (Core i3) for this installation.

3. Download

I downloaded Ruby Stack 2.2.2-0 Dev (64-bit) from this site:

The file was downloaded as bitnami-rubystack-2.2.2-0-dev-linux-x64-installer.run in my \Download\ directory.

4. Installation

Because I wanted to install as a root, not as a regular user, I did not run the installer by double clicking. I used the terminal window to run as a root user.

$ cd Downloads
$ sudo ./bitnami-rubystack-2.2.2-0-dev-linux-x64-installer.run

It opened a graphical installation wizard within a several seconds.

I accepted the default installation directory: /opt/rubystack-2.2.2-0/
(Note: the default directory will be different if you run the installer as a regular user, not root user).

When prompted, I entered passwords for MySQL and PostgreSQL servers.

I also selected SQLite as default data source for a sample Rails app installed.

That was all I needed to supply in order to install the RubyStack, which contained a fairly complete set of tools to run ruby/rails applications. In addition to Ruby it self (version 2.2.2p95) , it can optionally install the following items, which I accepted all.

What's interesting is that it can optionally install a bunch of php stuff, which may be convenient if I want to use phpMyAdmin and/or phpPgAdmin to manage my MySQL/PostgreSQL servers. It also gives me an environment in which I can run both ruby and php applications.

5. Test-Run

At the end of installation process, it asked me if I want to run it. I said yes. And here is the result screen (default page at http://localhost).

I clicked the link to run its sample Rails app.

6. Launch Ruby Stack Manager

The Ruby Stack Manager is a desktop application you can use to manually start/stop servers.

$ sudo /opt/rubystack-2.2.2-0/manager-linux-x64.run

7. Starting Servers Automatically At Start up

This installer for Linxu did not setup servers to start automatically. So I had to make some changes to do just that.

I found a simple instruction at http://stackoverflow.com/questions/22037222/how-to-start-bitnami-rubystack-environment-on-linux:

$ sudo -i
# cd /etc/init.d
# ln -s /opt/rubystack-2.2.2-0/ctlscript.sh bitnami-rubystack
# chmod +x bitnami-rubystack
# update-rc.d bitnami-rubystack defaults
# update-rc.d bitnami-rubystack enable
# exit

Now restart Ubuntu and check if its servers automatically start.

Check its webserver:

Check its MySQL server:
Check its PostgreSQL server:

8. Set up Environment Variable PATH

Finally, I set up environment variable PATH so that newly installed Ruby and related tools are readily available on my command line.

Open rubyconsole file:
$ leafpad /opt/rubystack-2.2.2-0/rubyconsole
And copy the line that begins with PATH="/opt/rubystack-2.2.2-0/...."
Then paste it on .bashrc file.
export PATH="/opt/rubystack-2.2.2-0/...$PATH"
Restart the terminal and test Ruby on command line.
$ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
$ rails -v
Rails 4.2.0
$ irb
irb(main):001:0> 1+2
=> 3
irb(main):002:0> exit