Category Archives: Linux

Another Installing Ruby and Rails on Ubuntu 14.04 Post

I’ve done it again… Needed to setup an Ubuntu machine to run a simple CRUD web app I maintain for a small ministry group. The app is built on Rails 3.2.8, Bootstrap 2 UI, Ruby 1.9.3, and uses SqlLite for a local single-file database. I began writing the app in April 2012, with small tweaks here and there each year since. It was my first real Rails app, and it still runs fine today as a contact management system for the 5-person distributed team who use it to track their ministry contacts and record various interactions they each have with their members.

I needed to move the app off of my own network which has plenty of internet and power outages throughout the year, so I decided to go with a cloud hosted option and chose Digital Ocean and one of their small “droplet” containers running a ready-to-use Ubuntu 14.04 system. I am able to get by with 1GB RAM AND 20gb storage, so the cost is $10 per month. Once the droplet is created using their very simple web portal, you get nothing more than a Linux box that you can access via SSH, VNC, or a terminal client like Putty (I installed Putty on my Windows machine using Chocolatey). It’s all terminal windows from there; no GUI at all.

So, to install Ruby and Rails, I logged into my droplet via a Putty terminal session and I followed one of the Digital Ocean help docs on how to install Ruby. It has you install RVM, and from that you can install the Ruby version that your app needs (in my case ruby-1.9.3-p392).

Here’s the RVM setup link from Digital Ocean:

Then I installed git so I could clone the source code repo of my app from my BitBucket account:

Then I had to install the Bundler gem so I could install all the other gems my apps needs to run:

To install the other gems in my app’s bundle list:

One snag… While all the gems were installing during “bundle install”, I got some error with the “nokogiri” gem, complaining that “libxml2 is missing“. I found a post on StackOverflow that showed my how to fix this problem:

Next, I ran “bundle install” again, and this time all gems installed fine.

So, now I tried to run my app using the built in Rails server:

and I got an error that something in the app “Could not find a Javascript runtime“, so, back to StockOverflow from a google, and I learned how to fix this issue:

So, finally after all this hacking around in the terminal window, the app ran fine using the built in Rails “WEBrick” server, which is all I need to host my app for about 5 users.

UPDATE: How to keep the WEBrick web server process running after I shut down the Putty console session I used to remote in and start up the app

I had used the Putty terminal app to remote into the VM droplet and start up the app using the rails command listed above, but when I closed the terminal session, the app process was killed and no one could access it from their web browsers. So, I found a StackExchange post that explained how to run a process in the background and tell it to ignore the shutting down of the terminal session so it would stay alive even after the terminal session ended. Here’e the link:

This “nohup” command starts a process and tells it to “ignore the hang up command when the terminal session is ended“, and we can also add the the “&” command line flag which means “run the process in the background“. With this we can now exit the terminal session and the process will continue running to server web requests.


As long as you are in the same terminal session as you started the process under, you can use the “jobs -l” command to see the running background process that you just started and see the process id. (Important: You’ll need the process id whenever you need to stop the Rail/WEBrick web server. Keep reading below…)

Here’s the output:

Now you can quit the terminal session, but the app will still keep running, so users can access the web app from their browser.

If you close this terminal session and log in later with a new terminal session later, it’s a little harder to find the process id of the Ruby/WEBrick session that you started in the original terminal session. However, we can find the process id using this command (notice we are running the output from “ps” through grep and filtering with “ruby” so that we will see only the ruby processes. You could also filter on “rails” just as well:

Stopping the process

Now, when you need to end (kill) the process to stop it, you have to know the process_id and use a special flag on the kill command, because the NOHUP command used to start the process will cause it to ignore the kill command. The command is: kill -9 [proceess_id]. (See notes above on how to learn the correct process_id.)

See this link for more info on this matter:


Another update…FTP access

A few days later I wanted to FTP upload some files to my Droplet on Digital Ocean. So, I found this really simple help post on the Digital Ocean community forum. It explains how you can use FileZilla and the SFTP secure protocol to easily connect to your Droplet from a FileZilla client session running on your local machine. There’s no configuration required in your droplet; it was built-in and ready to use on my Ubuntu 14.04 droplet that I based my VM on). Here’s the link:


Now, let me get back to my .Net/C#/Sql server/Entity Framework/MVC etc…

Connecting Ubuntu to Windows shares and DFS trees

I wanted to access a full DFS tree of shared folders from my Windows Server 2008R2 network from an Ubuntu Linux 12.04 machine running on the same network.

My first attempt at using “sudo mount –t cifs …blah-blah-blah… “ simply would not work. Sometimes it *seemed* to connect, but the folders were always empty. I wasted hours trying to figure out how to solve this.

Here is the original post I made on asking for help, back in March 2012:

I never solved the problem, that is, until I tried again in October 2012. I’m now running Ubuntu 12.04. So, I started all over… I tried a bunch of things from Google… And I finally got it working, even from “Connect to Server” in Nautilus!!!

These are the steps that finally made it work:

1. Enable/configure  proper WINS resolution

Follow this discussion to enable WINS resolution of Windows computer names on the network

Basically, it boils down to making this change:


2. Install SMBFS and KeyUtils

Every time I tried to call the MOUNT command, I was getting some error like “cifs_mount failed w/ return code = -22” that I could see by running dmesg | tail

So, some posts lead me to install these things:



Some posts state that the Samba stuff on Ubuntu is now deprecated or replaced by the newer CIFS stuff, and for some things, CIFS is the only thing needed,  but I assure you that the original Samba package is also required to connect to a DFS tree on a Windows server.

You will notice that “smbfs” will also install “cifs-utils” if it’s not already installed.

3. Configure smb.conf

I also made a few tweaks in /etc/samba/smb.conf. Uncomment these lines, and enter the correct values for your network:



4. Finally – a very important discovery…

This is the magic that finally made this work for me!!! Changing one little parameter…

I happened to notice this teensy little difference in one of my files compared to a blog post referenced in the only reply to my original question on SeverFault.

In the /etc/request-key.conf, I changed this line:

to this:

Note: This file is created by the  “keyutils” install. It was not present before, as I looked for it. I noticed that it appeared after installing keyutils via apt-get.

Two things to note here…

1. According to, the –c option is deprecated and is currently ignored. So, I don’t know why that option is included in the file in first place.

2. Warning: The suggested –t option has something to do with “trusting” the DNS server to resolve and retrieve kerberos session keys. I really don’t understand what it all means, but it is explained in the link listed right above here. All I know is, from my trial-and-error testing, this allows Windows DFS tree mounting to work, and it DOES NOT work without –t on this one line.

So, read the above link to learn more about this and make sure it’s safe for your environment. I tried several times to make it work without the –t option, but whenever it connected It gave me folder names from the DFS tree, but they were empty when viewed in Nautilus.

You need to restart your terminal window after making these changes and before going to the final step below:

Finally, let’s connect to a DFS tree or any other shared folder on the server.

Open a new Terminal window, and type the following:

The –verbose option adds logging info about the mount, which you can read from this command:

Or, from Nautilus file browser, you can use “Connect to Server” from the File menu, and make these entries in the dialog window:


Kaboom!!! It worked. At least for me.

Good luck to others who need this.