5 Things You Need to Know About Ubuntu 14.04 LTS

Ubuntu 14.04 LTS is the latest release of Ubuntu. Like other recent releases, there are no flashy big new features. Canonical has made some important changes, but they’re very easy to miss.

Overall, Ubuntu 14.04 has many under-the-hood improvements and new versions of software. It’s a solid upgrade, but nothing ground-breaking. Canonical is putting a lot of development effort into Ubuntu Mobile for smartphones and tablets.

You Can Disable Amazon Search Integration

Ubuntu has integrated Amazon search results in the Unity dash for a few releases now, but Ubuntu 14.04 marks the first time that users who stick to the LTS releases of Ubuntu will see these results.

Whenever you search for an application or file on your computer in the dash, your search is sent to Ubuntu’s servers. They forward your request to Amazon and show you Amazon search results. If you click an Amazon link and buy anything, Canonical gets a commission.

The dash isn’t necessarily the best place for these results. If you’re just using the dash to launch applications, the Amazon search results can get in the way. You may also not want to send every search you make to Ubuntu’s servers.


You can disable the Amazon search integration in one of two ways. The easiest way is to use the System Settings window (click the gear menu in the top-right corner and select System Settings). Click the Security & Privacy icon, click the Search tab, and toggle the “Include online search results” option to Off.


This will also disable all other online search results in the dash. To only disable the Amazon search results, you’ll need to uninstall the unity-lens-shopping package instead. Run the following command in a terminal window to remove Amazon search results, but not other online search results:

sudo apt-get remove unity-lens-shopping

Ubuntu also provides a quick link to Amazon on your launcher. Just right-click the Amazon icon and select Unlock from Launcher to remove it.


You Can Easily Disable the Global Menu

Ubuntu now includes a way to toggle off the global menu without removing packages. Menus for the focused window won’t appear on the top bar if you enable this. Instead, they’ll appear in the window’s title bar. This can decrease the distance you have to move the mouse and make Ubuntu seem more familiar if you’re used to Windows and traditional Linux desktops.

Like the global menu, this menu will only appear when you hover your mouse over the title bar. The menus will be hidden most of the time.


This option is also available in the System Settings dialog. To find it, open System Settings, click the Appearance icon, and select “In the window’s title bar” under Show the menus for a window.


You’ll Need to Move On From Ubuntu One

If you’ve followed the instructions in previous versions of Ubuntu, you probably created an Ubuntu One account. Ubuntu One was an integrated cloud storage service that provided a free 5 GB of storage space for your files and was even available on other operating systems.

Canonical is giving up on Ubuntu One — Google is offering 100 GB of space for $1.99 per month and Canonical can’t compete in this rush to the bottom. If you depend on Ubuntu One, you’ll need to move on to another cloud storage service before it shuts down on June 1, 2014. Ubuntu One software is no longer included with Ubuntu 14.04 LTS.

Dropbox will probably be the best cloud storage option for Ubuntu users who formerly used Ubuntu One. Dropbox officially supports Linux and provides two gigabytes of free storage space. It’s even available in the Ubuntu Software Center for easy installation.


Google Drive still doesn’t officially support Linux in spite of Google promising two years ago that it would be coming soon, while Microsoft’s OneDrive obviously doesn’t support Linux. If you want an encrypted cloud storage service — albeit one with a more complicated interface — you may want to check out SpiderOak instead.

Web App Integration Isn’t Working As Well

Ubuntu’s web app integration has changed. When you create a web app for a service like Gmail, Ubuntu will now use the same browser used on Ubuntu Mobile. This theoretically makes web apps more consistent between the desktop and mobile versions of Ubuntu, but it’s a problem if you actually want to use these apps. This browser doesn’t work anywhere near as well and doesn’t even have access to the Flash plug-in.

If you want launcher icons for your favorite web apps, you should probably skip Ubuntu’s native integration features. Instead, install the Chromium or Chrome web browsers and use the Tools > Create application shortcuts menu option to create launcher icons and separate windows for your preferred web apps.


We recommend Chromium or Chrome here because Firefox doesn’t provide this feature.


TRIM is Now Enabled By Default

We recently covered how previous releases of Ubuntu didn’t have TRIM support enabled by default. TRIM is an essential feature that ensures solid-state drives (SSDs) perform as quickly as possible. You don’t have to jump through any hoops to enable this on Ubuntu 14.04 — TRIM is now enabled by default. If you use an SSD but have never enabled TRIM in the past, you should get better disk performance on Ubuntu 14.04.

TRIM is only enabled by default on Intel and Samsung SSDs, as it can apparently cause problems on SSDs with buggy firmware. It’s probably best to leave TRIM disabled if Ubuntu doesn’t think it will work properly on your SSD.


How to Install ImageMagick on CentOS, RHEL and Ubuntu

ImageMagick is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats like GIFJPEGPNGPostscript, and TIFF. We can also use ImageMagick toresizeflip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

ImageMagick is typically used from command line. Also we can use it from any programming language by using its interface like Magick.NET (.Net),IMagick (PHP), PerlMagick (Perl) etc.

Step 1. Install Required Packages

First we need to install required packages in order to install ImageMagic and IMagick PHP extension.

For CentOS,RHEL Users:
# yum install gcc php-devel php-pear
For Ubuntu Users:
$ sudo apt-get install gcc

Step 2. Install ImageMagick

After installing required packages, let’s install ImageMagick using following command.

For CentOS,RHEL Users:
# yum install ImageMagick ImageMagick-devel
For Ubuntu Users:
$ sudo apt-get install imagemagick

Step 3. Install ImageMagick PHP Extension

At this point you have successfully installed ImageMagick package on your system. Now are are going to install ImageMagick php extension, So that we can use it through php code.

For CentOS,RHEL Users:
# pecl install imagick
# echo "extension=imagick.so" > /etc/php.d/imagick.ini
For Ubuntu Users:
$ sudo apt-get install php5-imagick

Step 4. Restart Apache and Check Extension

After completing above steps you need to reload apache service to enable php exension using following command

CentOS,RHEL Users:
# service httpd reload

Ubuntu Users:
# service apache2 reload

(Originated from http://tecadmin.net/install-imagemagick-on-linux/#)

How To Install Redmine on Ubuntu 12.10

Redmine is a project management software that you can install on your cloud server. It can be used to track bugs, collaborate on features, and track progress of any project.


We begin by spinning up a Ubuntu 12.10 x64 cloud server.

Next, we will need to install Apache, MySQL, mod_passenger, and Ruby.

export DEBIAN_FRONTEND=noninteractive
apt-get install -y apache2 mysql-server mysql-client libapache2-mod-passenger software-properties-common librmagick-ruby ruby-rmagick redmine redmine-mysql
gem install bundler mysql2

This will install Redmine in /usr/share/redmine so we will want to create a symbolic link to Apache’s default DocumentRoot (/var/www):

ln -s /usr/share/redmine/public /var/www

Now we need to configure Apache with mod_passenger and tell it to follow symlinks:

sed -i '/mod_passenger.c/aPassengerDefaultUser www-data' /etc/apache2/mods-available/passenger.conf
sed -i '//a\\tRailsBaseURI \/public\n\tPassengerResolveSymlinksInDocumentRoot on' /etc/apache2/sites-available/default

Your Apache configuration files should look like this:

Restart Apache for settings to take effect:

service apache2 restart

Now you can navigate to your cloud server’s IP address /public folder and login ( in our case):

Login: admin
Password: admin

Make sure you change your password by navigating to /public/my/password ( in our case).

And you are all done!

(Originated from https://www.digitalocean.com/community/articles/how-to-install-redmine-on-ubuntu-12-10)

How To Use Cron To Automate Tasks On a VPS


One of the most standard ways to run tasks in the background on Linux machines is with cron jobs. They’re useful for scheduling tasks on the VPS and automating different maintenance-related jobs. “Cron” itself is a daemon (or program) that runs in the background. The schedule for the different jobs that are run is in a configuration file called “crontab.”


Almost all distros have a form of cron installed by default. However, if you’re using a system that doesn’t have it installed, you can install it with the following commands:

For Ubuntu/Debian:

sudo apt-get update
sudo apt-get install cron

For Cent OS/Red Hat Linux:

sudo yum update
sudo yum install vixie-cron crontabs

You’ll need to make sure it runs in the background too:

sudo /sbin/chkconfig crond on
sudo /sbin/service crond start


Here is an example task we want to have run:

5 * * * * curl http://www.google.com

The syntax for the different jobs we’re going to place in the crontab might look intimidating. It’s actually a very succinct and easy-to-parse if you know how to read it. Every command is broken down into:

  • Schedule
  • Command

The command can be virtually any command you would normally run on the command line. The schedule component of the syntax is broken down into 5 different options for scheduling in the following order:

  • minute
  • hour
  • day of the month
  • month
  • day of the week


Here is a list of examples for some common schedules you might encounter while configuring cron.

To run a command every minute:

* * * * *

To run a command every 12th minute on the hour:

12 * * * *

You can also use different options for each placeholder. To run a command every 15 minutes:

0,15,30,45 * * * *

To run a command every day at 4:00am, you’d use:

0 4 * * *

To run a command every Tuesday at 4:00am, you’d use:

0 4 * * 2

You can use division in your schedule. Instead of listing out 0,15,30,45, you could also use the following:

*/4 2-6 * * *

Notice the “2-6” range. This syntax will run the command between the hours of 2:00am and 6:00am.

The scheduling syntax is incredibly powerful and flexible. You can express just about every possible time imaginable.


Once you’ve settled on a schedule and you know the job you want to run, you’ll have to have a place to put it so your daemon will be able to read it. There are a few different places, but the most common is the user’s crontab. If you’ll recall, this is a file that holds the schedule of jobs cron will run. The files for each user are located at /var/spool/cron/crontab, but they are not supposed to be edited directly. Instead, it’s best to use the crontab command.

You can edit your crontab with the following command:

crontab -e

This will bring up a text editor where you can input your schedule with each job on a new line.

If you’d like to view your crontab, but not edit it, you can use the following command:

crontab -l

You can erase your crontab with the following command:

crontab -r

If you’re a privileged user, you can edit another user’s by specifying crontab -u <user> -e


For every cron job that gets executed, the user’s email address that’s associated with that user will get emailed the output unless it is directed into a log file or into /dev/null. The email address can be manually specified if you provide a “MAILTO” setting at the top of the crontab. You can also specify the shell you’d like run, the path where to search for the cron binary and the home directory with the following example:

First, let’s edit the crontab:

crontab -e

Then, we’ll edit it like so:

#This is a comment
* * * * * echo ‘Run this command every minute’

This particular job will output “Run this command every minute.” That output will get emailed every minute to the “example@digitalocean.com” email address I specified. Obviously, that might not be an ideal situation. As mentioned, we can also pipe the output into a log file or into an empty location to prevent getting an email with the output.

To append to a log file, it’s as simple as:

* * * * * echo ‘Run this command every minute’ >> file.log

Note: “>>” appends to a file.

If you want to pipe into an empty location, use /dev/null. Here is a PHP script that gets executed and runs in the background.

* * * * * /usr/bin/php /var/www/domain.com/backup.php > /dev/null 2>&1

Restricting Access

Restricting access to cron is easy with the /etc/cron.allow and /etc/cron.deny files. In order to allow or deny a user, you just need to place their username in one of these files, depending on the access required. By default, most cron daemons will assume all users have access to cron unless one of these file exists. To deny access to all users and give access to the user tdurden, you would use the following command sequence:

echo ALL >>/etc/cron.deny
echo tdurden >>/etc/cron.allow

First, we lock out all users by appending “ALL” to the deny file. Then, by appending the username to the allow file, we give the user access to execute cron jobs.

Special Syntax

There are several shorthand commands you can use in your crontab file to make administering a little easier. They are essential shortcuts for the equivalent numeric schedule specified:

  • @hourly – Shorthand for 0 * * * *
  • @daily – Shorthand for 0 0 * * *
  • @weekly – Shorthand for 0 0 * * 0
  • @monthly – Shorthand for 0 0 1 * *
  • @yearly – Shorthand for 0 0 1 1 *

and @reboot, which runs the command once at startup.

Note: Not all cron daemons can parse this syntax (particularly older versions), so double-check it works before you rely on it.

To have a job that runs on start up, you would edit your crontab file (crontab -e) and place a line in the file similar to the following:

@reboot echo "System start up"

This particular command would get executed and then emailed out to the user specified in the crontab.

How To Install and Setup Postfix on Ubuntu 12.04

About Postfix

Postfix is a free, open source Mail Transfer Agent which works to route and deliver email.


Before installing Postfix, you will need to have a Fully Qualified Domain Name pointing to the server that you will be using.

You can find instructions on that here:
How to Set Up a Host Name with DigitalOcean

Install Postfix

Postfix can easily be installed through apt-get:

sudo apt-get install postfix

During the installation, you will see a dialogue box appear, asking you which kind of installation you would prefer. Select “Internet Site”.

Follow up by entering the name of your domain.

Once Postfix is installed there are a few steps that need to be taken before it is fully functional.

Configure Postfix

Once Postfix is installed, go ahead and open the main configuration file.

sudo nano /etc/postfix/main.cf

There are a few changes that should be made in this file.

myhostname = example.com

Put in name of your domain into myhostname.

If you want to have mail forwarded to other domains, replace alias_maps with virtual_alias_maps and point it to /etc/postfix/virtual.

virtual_alias_maps = hash:/etc/postfix/virtual

The rest of the entries are described below

mydestination defines the domains that postfix is going to serve, in this case—localhost and your domain (eg. example.com).

relayhost can be left, as is the default, empty.

mynetworks defines who can use the mail server. This should be set to local—creating an open mail server is asking for SPAM. This will usually have damaging effects on your server and may put you in line for discipline from your web hosting provider.

If it is not set up by default, as it should be, make sure you have the following text on that line:

mynetworks = [::ffff:]/104 [::1]/128

The rest of the lines are set by default. Save, exit, and reload the configuration file to put your changes into effect:

sudo /etc/init.d/postfix reload

Configure Additional Emails

To redirect emails to specific emails, you can add users to the alias file. By default each user on the server will be able to read emails directed to their username@domain-name.com.

Open up the the alias database:

sudo nano /etc/postfix/virtual

Within that file, enter in the names of your users. For example:

sales@example.com username1
me@example.com username2

Once you are finished, save, exit, and run the following command:

postmap /etc/postfix/virtual

The last step is to reload postfix once more.

sudo /etc/init.d/postfix reload


Once Postfix is installed, mail can be sent to and from the server, although without a mail server like Dovecot or Cyrus, you will only be able to see the email on the server.

You send out email from the command line with the command “sendmail” and where you want the mail sent to:

sendmail sample-email@example.org

Once you enter the command, type your message, and when it is completed, you can send it off with ctrl-D

Incoming mail gets delivered into /var/mail/username

Install Ruby on Rails – Ubuntu Linux

Install Ruby on Rails 4.1 on Ubuntu Linux. Up-to-date, detailed instructions for the Rails newest release. How to install Rails 4.1, the newest version of Rails, on Ubuntu.

This in-depth installation guide is used by developers to configure their working environment for real-world Rails development. This guide doesn’t cover installation of Ruby on Rails for a production server.

To develop with Rails on Ubuntu, you’ll need Ruby (an interpreter for the Ruby programming language) plus gems (software libraries) containing the Rails web application development framework.

For an overview of what’s changed in each Rails release, see a Ruby on Rails Release History.

What is the RailsApps Project?

This is an article from the RailsApps project. The RailsApps project provides example applications that developers use as starter apps. Hundreds of developers use the apps, report problems as they arise, and propose solutions. Rails changes frequently; each application is known to work and serves as your personal “reference implementation.” Support for the project comes from subscribers. If this article is useful, please support us and join the RailsApps project.

Ruby on Rails on Ubuntu

Ubuntu is a popular platform for Rails development, as are other Unix-based operating systems such as Mac OS X. Installation is relatively easy and widespread help is available in the Rails developer community.

Use a Ruby Version Manager

You’ll need an easy way to switch between Ruby versions. Just as important, you’ll have a dependency mess if you install gems into the system environment. I recommend RVM to manage Ruby versions and gems because it is popular, well-supported, and full-featured. If you are an experienced Unix administrator, you can consider alternatives such as Chruby, Sam Stephenson’s rbenv, or others on this list.

Conveniently, you can use RVM to install Ruby.

Don’t Install Ruby from a Package

Ubuntu provides a package manager system for installing system software. You’ll use this to prepare your computer before installing Ruby. However, don’t use apt-get to install Ruby. The package manager will install an outdated version of Ruby. And it will install Ruby at the system level (for all users). It’s better to use RVM to install Ruby within your user environment.

Hosted Development

You can use Ruby on Rails without actually installing it on your computer. Hosted development, using a service such as Nitrous.io, means you get a computer “in the cloud” that you use from your web browser. Any computer can access the hosted development environment, though you’ll need a broadband connection. Nitrous.io is free for small projects.

Using a hosted environment means you are no longer dependent on the physical presence of a computer that stores all your files. If your computer crashes or is stolen, you can continue to use your hosted environment from any other computer. Likewise, if you frequently work on more than one computer, a hosted environment eliminates the difficulty of maintaining duplicate development environments. For these reasons some developers prefer to “work in the cloud” using Nitrous.io. For more on Nitrous.io, see the article Ruby on Rails with Nitrous.io. Nitrous.io is a good option if you have trouble installing Ruby on Rails on your computer.

Prepare Your System

You’ll need to prepare your computer with the required system software before installing Ruby on Rails.

You’ll need superuser (root) access to update the system software.

Update your package manager first:

$ sudo apt-get update

This must finish without error or the following step will fail.

Install Curl:

$ sudo apt-get install curl

You’ll use Curl for installing RVM.

Install Ruby Using RVM

Use RVM, the Ruby Version Manager, to install Ruby and manage your Rails versions.

If you have an older version of Ruby installed on your computer, there’s no need to remove it. RVM will leave your “system Ruby” untouched and use your shell to intercept any calls to Ruby. Any older Ruby versions will remain on your system and the RVM version will take precedence.

Ruby 2.1.1 was current when this was written. You can check for the current recommended version of Ruby. RVM will install the newest stable Ruby version.

The RVM website explains how to install RVM. Here’s the simplest way:

$ \curl -L https://get.rvm.io | bash -s stable --ruby

Note the backslash before “curl” (this avoids potential version conflicts).

The “—ruby” flag will install the newest version of Ruby.

RVM includes an “autolibs” option to identify and install system software needed for your operating system. See the article RVM Autolibs: Automatic Dependency Handling and Ruby 2.0 for more information.

If You Already Have RVM Installed

If you already have RVM installed, update it to the latest version and install Ruby:

$ rvm get stable --autolibs=enable
$ rvm install ruby
$ rvm --default use ruby-2.1.1

Installation Troubleshooting and Advice

RVM Troubleshooting

If you have trouble installing Ruby with RVM, you can get help directly from the RVM team using the IRC (Internet Relay Chat) channel #rvm on irc.freenode.net:


If you’ve never used IRC, it’s worthwhile to figure out how to use IRC because the RVM team is helpful and friendly. IRC on freenode requires registration (see how to register).

Install Node.js

Since Rails 3.1, a JavaScript runtime has been needed for development on Ubuntu Linux. The JavaScript runtime is required to compile code for the Rails asset pipeline. For development on Ubuntu Linux it is best to install the Node.js server-side JavaScript environment.

$ sudo apt-get install nodejs

and set it in your $PATH.

If you don’t install Node.js, you’ll need to add this to the Gemfile for each Rails application you build:

gem 'therubyracer'

Check the Gem Manager

RubyGems is the gem manager in Ruby.

Check the installed gem manager version:

$ gem -v

You should have:

Use gem update --system to upgrade the Ruby gem manager if necessary.

RVM Gemsets

Not all Rails developers use RVM to manage gems, but many recommend it.

Display a list of gemsets:

$ rvm gemset list

gemsets for ruby-2.1.1
=> (default)

Only the “default” and “global” gemsets are pre-installed.

If you get an error “rvm is not a function,” close your console and open it again.

RVM’s Global Gemset

See what gems are installed in the “global” gemset:

$ rvm gemset use global
$ gem list

A trouble-free development environment requires the newest versions of the default gems.

Several gems are installed with Ruby or the RVM default gemset:

To get a list of gems that are outdated:

$ gem outdated
### list not shown for brevity

To update all stale gems:

$ gem update
### list not shown for brevity

In particular, rake should be updated to version 10.2.1 or newer.

Faster Gem Installation

By default, when you install gems, documentation files will be installed. Developers seldom use gem documentation files (they’ll browse the web instead). Installing gem documentation files takes time, so many developers like to toggle the default so no documentation is installed.

Here’s how to speed up gem installation by disabling the documentation step:

$ echo "gem: --no-document" >> ~/.gemrc

This adds the line gem: --no-document to the hidden .gemrc file in your home directory.

Staying Informed

You can stay informed of new gem versions by creating an account at RubyGems.org and visiting your dashboard. Search for each gem you use and “subscribe” to see a feed of updates in the dashboard (an RSS feed is available from the dashboard).

After you’ve built an application and set up a GitHub repository, you can stay informed with Gemnasium or VersionEye. These services survey your GitHub repo and send email notifications when gem versions change. Gemnasium and VersionEye are free for public repositories with a premium plan for private repositories.

Rails Installation Options

Check for the current version of Rails. Rails 4.1.0.rc2 is the newest pre-release version of Rails. Rails 4.0.4 is the current stable release.

You can install Rails directly into the global gemset. However, many developers prefer to keep the global gemset sparse and install Rails into project-specific gemsets, so each project has the appropriate version of Rails.

If you install Rails at this point, you will install it into the global gemset.

Instead, make a gemset just for the pre-release version of Rails:

$ rvm use ruby-2.1.1@rails4.1 --create

Or, if you want to stay with the current stable release:

$ rvm use ruby-2.1.1@rails4.0 --create

Here are the options you have for installing Rails.

If you want the newest beta version or release candidate, you can install with --pre.

$ gem install rails --pre
$ rails -v

If you want the most recent stable release:

$ gem install rails
$ rails -v

Or you can get a specific version.

For example, if you want the Rails 3.2.17 release:

$ gem install rails --version=3.2.17
$ rails -v

Create a Workspace Folder

You’ll need a convenient folder to store your Rails projects. You can give it any name, such as code/ or projects/. For this tutorial, we’ll call itworkspace/.

Create a projects folder and move into the folder:

$ mkdir workspace
$ cd workspace

This is where you’ll create your Rails applications.

New Rails Application

Here’s how to create a project-specific gemset, installing Rails, and creating a new application.

$ mkdir myapp
$ cd myapp
$ rvm use ruby-2.1.1@myapp --ruby-version --create
$ gem install rails --pre
$ rails new .

We’ll name the new application “myapp.” Obviously, you can give it any name you like.

With this workflow, you’ll first create a root directory for your application, then move into the new directory.

With one command you’ll create a new project-specific gemset. The option “—ruby-version” creates .ruby-version and .ruby-gemset files in the root directory. RVM recognizes these files in an application’s root directory and loads the required version of Ruby and the correct gemset whenever you enter the directory.

When we create the gemset, it will be empty (though it inherits use of all the gems in the global gemset). We immediately install Rails. The commandgem install rails installs the most recent release of Rails.

Finally we run rails new .. We use the Unix “dot” convention to refer to the current directory. This assigns the name of the directory to the new application.

This approach is different from the way most beginners are taught to create a Rails application. Most instructions suggest using rails new myapp to generate a new application and then enter the directory to begin work. Our approach makes it easy to create a project-specific gemset and install Rails before the application is created.

The rails new command generates the default Rails starter app. If you wish, you can use the Rails Composer tool to generate a starter application with a choice of basic features and popular gems.

Quick Test

For a “smoke test” to see if everything runs, display a list of Rake tasks.

$ rake -T

There’s no need to run bundle exec rake instead of rake when you are using RVM (see RVM and bundler integration).

This concludes the instructions for installing Ruby and Rails. Read on for additional advice and tips.

Rails Starter Apps

The starter application you create with rails new is very basic.

Use the Rails Composer tool to build a full-featured Rails starter app.

You’ll get a choice of starter applications with basic features and popular gems.

Here’s how to generate a new Rails application using the Rails Composer tool:

Using the conventional approach:

$ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb

Or, first creating an empty application root directory:

$ mkdir myapp
$ cd myapp
$ rvm use ruby-2.1.1@myapp --ruby-version --create
$ gem install rails
$ rails new . -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb

The -m option loads an application template that is hosted on GitHub.

You can add the -T flags to skip Test::Unit if you are using RSpec for testing.

You can add the -O flags to skip Active Record if you are using a NoSQL datastore such as MongoDB.

If you get an error “OpenSSL certificate verify failed” when you try to generate a new Rails app, see the article OpenSSL errors and Rails.

Rails Tutorials and Example Applications

The RailsApps project provides example apps that show how real-world Rails applications are built. Each example is known to work and can serve as your personal “reference implementation”. Each is an open source project. Dozens of developers use the apps, report problems as they arise, and propose solutions as GitHub issues. Purchasing a subscription for the tutorials gives the project financial support.

Example Applications for Rails 4.1 Tutorial Comments
Rails and Bootstrap Tutorial starter app for Rails and Bootstrap
Rails and Foundation Quickstart Guide starter app for Rails and Zurb Foundation
OmniAuth and Rails OmniAuth for authentication
Devise and Rails Devise for authentication
Devise and Pundit and Rails Pundit for authorization
Example Applications for Rails 4.0 Tutorial Comments
Learn Rails Learn Ruby on Rails introduction to Rails for beginners

Adding a Gemset to an Existing Application

If you’ve already created an application with the command rails new myapp, you can still create a project-specific gemset. Here’s how to create a gemset for an application named “myapp” and create .ruby-version and .ruby-gemset files in the application’s root directory:

$ rvm use ruby-2.1.1@myapp --ruby-version --create

You’ll need to install Rails and the gems listed in your Gemfile into the new gemset by running:

$ gem install rails
$ bundle install

Specifying a Gemset for an Existing Application

If you have already created both an application and a gemset, but not .ruby-version and .ruby-gemset files, here’s how to add the files. For example, if you want to use an existing gemset named “ruby-2.1.1@myapp”:

$ echo "ruby-2.1.1" > .ruby-version
$ echo "myapp" > .ruby-gemset

Using .ruby-version and .ruby-gemset files means you’ll automatically be using the correct Rails and gem version when you switch to your application root directory on your local machine.

Databases for Rails

Rails uses the SQLite database by default. RVM installs SQLite and there’s nothing to configure.

Though SQLite is adequate for development (and even some production applications), a new Rails application can be configured for other databases. The command rails new myapp --database= will show you a list of supported databases.

Supported for preconfiguration are: mysql, oracle, postgresql, sqlite3, frontbase, ibm_db, sqlserver, jdbcmysql, jdbcsqlite3, jdbcpostgresql, jdbc.

For example, to create a new Rails application to use PostgreSQL:

$ rails new myapp --database=postgresql

The --database=postgresql parameter will add the pg database adapter gem to the Gemfile and create a suitable config/database.yml file.

Don’t use the --database= argument with the Rails Composer tool. You’ll select a database from a menu instead.


If you wish to run your own servers, you can deploy a Rails application using Capistrano deployment scripts. However, unless system administration is a personal passion, it is much easier to deploy your application with a “platform as a service” provider such as Heroku.


For easy deployment, use a “platform as a service” provider such as:

For deployment on Heroku, see the article:


By design, Rails encourages practices that avoid common web application vulnerabilities. The Rails security team actively investigates and patches vulnerabilities. If you use the most current version of Rails, you will be protected from known vulnerabilities. See the Ruby On Rails Security Guide for an overview of potential issues and watch the Ruby on Rails Security Mailing List for announcements and discussion.

Your Application’s Secret Token

Rails uses a session store to provide persistence between page requests. The default session store uses cookies. To prevent decoding of cookie data and hijacking a session, Rails encrypts cookie data using a secret key. When you create a new Rails application using the rails new command, a unique secret key is generated. If you’ve used the Rails Composer tool to generate the application, the application’s secret token will be unique, just as with any Rails application generated with the rails new command.

In Rails 4.1, the file config/secrets.yml contains secret tokens for development and production.

In Rails 4.0, the config/initializers/secret_token.rb file contains the secret token.

Take care to hide the secret token you use in production. Don’t expose it in a public GitHub repo, or people could change their session information, and potentially access your site without permission. It’s best to set the secret token in a Unix shell variable.

If you need to create a new secret token:

$ rake secret

The command rake secret generates a new random secret you can use. The command won’t install the key; you have to copy the key from the console output to the appropriate file.

Where to Get Help

Your best source for help with problems is Stack Overflow. Your issue may have been encountered and addressed by others.

You can also try Rails Hotline, a free telephone hotline for Rails help staffed by volunteers.

Compile FFmpeg on Ubuntu, Debian, or Mint

This guide for supported releases of UbuntuDebian, and Linux Mint will provide a local install of the latest FFmpeg tools and libraries including several external encoding and decoding libraries (codecs). This will not interfere with repository packages.

You may also refer to the Generic FFmpeg Compilation Guide for additional information.

Recent ​static builds are also available for lazy people or those who are unable to compile.

Get the Dependencies

Copy and paste the whole code box for each step.

sudo apt-get update
sudo apt-get -y install autoconf automake build-essential libass-dev libgpac-dev \
  libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev \
  libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev
mkdir ~/ffmpeg_sources
  • Server users can omit the ffplay and x11 dependencies: libsdl1.2-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxfixes-dev.
  • Lucid lacks the package libva-dev. This can be ignored.

Compilation & Installation

You can compile ffmpeg to your liking. If you do not require certain encoders you may skip the relevant section and then remove the appropriate ./configure option in FFmpeg. For example, if libopus is not needed, then skip that section and then remove --enable-libopus from the Install FFmpeg section.

This guide will create several directories in your home directory:

  • ffmpeg_sources – Where the source files will be downloaded.
  • ffmpeg_build – Where the files will be built and libraries installed.
  • bin – Where the resulting binaries (ffmpegffplayffserverx264, and yasm) will be installed.

You can easily undo any of this as shown in Reverting Changes Made by This Guide.


The first step is to compile Yasm which is an assembler used by x264 and FFmpeg. Ubuntu 13.10, Ubuntu 13.04, and Mint 15 users can alternatively install the yasm package from the repository instead of compiling.

cd ~/ffmpeg_sources
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make install
make distclean
export "PATH=$PATH:$HOME/bin"


H.264 video encoder. See the x264 Encoding Guide for more information and usage examples. NOTE: FFmpeg’s ./configure requires –enable-libx264 and –extra-libs=”-ldl”.

cd ~/ffmpeg_sources
wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
tar xjvf last_x264.tar.bz2
cd x264-snapshot*
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static
make install
make distclean


AAC audio encoder. See the AAC Encoding Guide for more information and usage examples.

cd ~/ffmpeg_sources
wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master
unzip fdk-aac.zip
cd mstorsjo-fdk-aac*
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make install
make distclean


MP3 audio encoder.

Most users can install the repository package:

sudo apt-get install libmp3lame-dev

Ubuntu 10.04 and Debian Squeeze users must compile:

sudo apt-get install nasm
cd ~/ffmpeg_sources
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared
make install
make distclean


Opus audio decoder and encoder.

cd ~/ffmpeg_sources
wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz
tar xzvf opus-1.1.tar.gz
cd opus-1.1
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make install
make distclean


VP8/VP9 video encoder and decoder. See the vpx (WebM) Encoding Guide for more information and usage examples.

cd ~/ffmpeg_sources
wget http://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
tar xjvf libvpx-v1.3.0.tar.bz2
cd libvpx-v1.3.0
./configure --prefix="$HOME/ffmpeg_build" --disable-examples
make install
make clean


Note: Server users should remove --enable-x11grab.

cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" \
   --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --extra-libs="-ldl" --enable-gpl \
   --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora \
   --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
make install
make distclean
hash -r


Installation is now complete and ffmpeg is now ready for use. Your newly compiled FFmpeg programs are in ~/bin. To use it:

  • Navigate to ~/bin and execute the binary: cd ~/bin && ./ffmpeg -i ~/input.mp4 ~/videos/output.mkv (notice the ./)
  • Or you can use the full path to the binary: /home/yourusername/bin/ffmpeg -i ../input.mp4 ../videos/output.mkv
  • Or if you simply want to just issue the ffmpeg command and have your shell use your compiled binary see the Persistent Environment Variables section below.

Persistent Environment Variables

You can tell your shell (assuming you’re using Bash) to persistantly use your new ffmpeg in ~/bin. The first command will allow you to simply run man ffmpeg to get the FFmpeg man pages. The second command will source ~/.profile which will add ~/bin to your $PATH. In short, the following commands will allow you to simply type ffmpeg and man ffmpeg in your terminal and they will “just work”:

echo "MANPATH_MAP $HOME/bin $HOME/ffmpeg_build/share/man" >> ~/.manpath
. ~/.profile


  • This may reset custom variables in the current shell session.
  • This assumes you are using the default ~/.profile (and therefore ~/.bashrc).
  • This assumes you are using Bash shell.
  • Sourcing the default ~/.profile will also source ~/.bashrc.
  • You may have to log out and then log in for man ffmpeg to work.
  • Don’t worry: you can undo any of this as shown in Reverting Changes Made by This Guide.

See ​Ubuntu Wiki: Persistent Environment Variables for more info.

Additional Notes

  • See the x264 Encoding Guide for some encoding examples.
  • If you do not see FFmpeg developers in your ffmpeg console output then something went wrong and you’re probably using the ​fake “ffmpeg” from the repository.
  • HTML formatted documentation is available in ~/ffmpeg_build/share/doc/ffmpeg.
  • You can keep the ffmpeg_sources directory if you plan on updating later. See Updating FFmpeg below for more details followed by instructions for reverting all changes made by this guide.

Updating FFmpeg

Development of FFmpeg is active and an occasional update can give you new features and bug fixes. First you need to delete (or move) the old files:

rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffserver,vsyasm,x264,yasm,ytasm}

Now just follow the guide from the beginning.

Reverting Changes Made by This Guide

rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffserver,vsyasm,x264,yasm,ytasm}
sudo apt-get autoremove autoconf automake build-essential libass-dev libgpac-dev \
  libmp3lame-dev libopus-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev \
  libvorbis-dev libvpx-dev libx11-dev libxext-dev libxfixes-dev texi2html zlib1g-dev
sed -i '/ffmpeg_build/c\' ~/.manpath
hash -r

If You Need Help

Feel free to ask questions at the #ffmpeg IRC channel or the ​ffmpeg-user mailing list.

HowTo Install Redmine on Ubuntu step by step

Prerequisite: check your ubuntu version against intended Redmine version

Before using or studying this guide you should check which Redmine version you are going for. Be aware that only latest stable releases will be fully compatible with current releases of plugins.
To check redmine versions versus your ubuntu version have a look at http://www.ubuntuupdates.org/pm/redmine

Generally you could also consider only installing ruby from ubuntu-repos and then heading for a release of redmine from redmine’s download page:http://www.redmine.org/projects/redmine/wiki/Download (this is the more common way of installing redmine on ubuntu). In this case this guide is not suited for you and you should check for an alternate guide. Google provides lots of resources for this alternate installation procedure.

If you are sure that you want to install from ubuntu-repositories, keep on reading:


This tutorial walks you step-by-step through installing Redmine on a clean/fresh Ubuntu 12.04 installation. This is intended to be a complete cookbook method for getting Redmine installed and running. It makes no assumptions about other things being installed or configured. Since I have had some issues when using the graphical package managers, we will be doing this from the command line prompt to keep things as clear and clean as possible.

I recommend that you install any Ubuntu updates prior to beginning this process. There are almost always some waiting to be applied after Ubuntu is first set up.

Prerequisites: Apache, mod-passenger, and MySQL

There are several support packages that we will install first. The apache installation is pretty simple if you just follow the prompts and accept the defaults.

$ sudo apt-get install apache2 libapache2-mod-passenger

Installing mysql takes just a little more, so the details are spelled out.

$ sudo apt-get install mysql-server mysql-client

The installation process for mysql is going to prompt you for a password for the “root” access for the database server, then ask you to confirm the password in a follow-up screen. This sets the database adminstration password.

Package configuration                                                           

  ┌────────────────────┤ Configuring mysql-server-5.5 ├─────────────────────┐   
  │ While not mandatory, it is highly recommended that you set a password   │   
  │ for the MySQL administrative "root" user.                               │   
  │                                                                         │   
  │ If this field is left blank, the password will not be changed.          │   
  │                                                                         │   
  │ New password for the MySQL "root" user:                                 │   
  │                                                                         │   
  │ _______________________________________________________________________ │   
  │                                                                         │   
  │                                 <Ok>                                    │   
  │                                                                         │   

  ┌────┤ Configuring mysql-server-5.5 ├──────────┐
  │                                              │
  │ Repeat password for the MySQL "root" user.   │
  │                                              │
  │                                              │
  │ ____________________________________________ │
  │                                              │
  │                   <Ok>                       │
  │                                              │

Installing and configuring the Ubuntu Redmine package

Now it is time to install redmine itself.

$ sudo apt-get install redmine redmine-mysql

You want to allow dbconfig-common to configure the database when prompted so select Yes from the prompt in the panel below.

Package configuration                                                           

 ┌──────────────────────────┤ Configuring redmine ├──────────────────────────┐  
 │                                                                           │  
 │ The redmine/instances/default package must have a database installed and  │  
 │ configured before it can be used.  This can be optionally handled with    │  
 │ dbconfig-common.                                                          │  
 │                                                                           │  
 │ If you are an advanced database administrator and know that you want to   │  
 │ perform this configuration manually, or if your database has already      │  
 │ been installed and configured, you should refuse this option.  Details    │  
 │ on what needs to be done should most likely be provided in                │  
 │ /usr/share/doc/redmine/instances/default.                                 │  
 │                                                                           │  
 │ Otherwise, you should probably choose this option.                        │  
 │                                                                           │  
 │ Configure database for redmine/instances/default with dbconfig-common?    │  
 │                                                                           │  
 │                    <Yes>                       <No>                       │  
 │                                                                           │  

Then you want to provide the “root” password for the database, so that the installer can create the redmine database. This is the password set when you installed mysql.

Package configuration                                                           

 ┌──────────────────────────┤ Configuring redmine ├──────────────────────────┐  
 │ Please provide the password for hte administrative account with which     │  
 │ this package should create its MySQL database and user.                   │  
 │                                                                           │  
 │ Password of the database's administrative user:                           │  
 │                                                                           │  
 │ ******__________________________________________________________________  │  
 │                                                                           │  
 │                   <Ok>                       <Cancel>                     │  
 │                                                                           │  

Tell the redmine installer we are using mysql for this installation by highlighting “mysql” from the list of database choices:

Package configuration                                                           

 ┌──────────────────────────┤ Configuring redmine ├──────────────────────────┐  
 │ The redmine/instances/default package can be configured to use one of     │  
 │ several database types. Below, you will be presented with the available   │  
 │ choices.                                                                  │  
 │                                                                           │  
 │ Database type to be used by redmine/instances/default:                    │  
 │                                                                           │  
 │                                  sqlite3                                  │  
 │                                  pgsql                                    │  
 │                                  mysql                                    │  
 │                                                                           │  
 │                                                                           │  
 │                    <Ok>                        <Cancel>                   │  
 │                                                                           │  

Now you are asked to provide a password that will be used to protect the redmine database. Redmine itself will use this when it wants to access mysql.

Package configuration                                                           

 ┌──────────────────────────┤ Configuring redmine ├──────────────────────────┐  
 │ Please provide a password for redmine/instances/default to register with  │  
 │ the database server.  If left blank, a random password will be            │  
 │ generated.                                                                │  
 │                                                                           │  
 │ MySQL application password for redmine/instances/default:                 │  
 │                                                                           │  
 │ *******__________________________________________________________________ │  
 │                                                                           │  
 │                    <Ok>                        <Cancel>                   │  
 │                                                                           │  

Now confirm the redmine password.

Package configuration                                                           

   ┌────┤ Configuring redmine ├─────┐                       
   │                                │                       
   │                                │                       
   │ Password confirmation:         │                       
   │                                │                       
   │ *******_______________________ │                       
   │                                │                       
   │     <Ok>         <Cancel>      │                       
   │                                │                       

Configuring Apache

You need to modify two files for apache. The first is /etc/apache2/mods-available/passenger.conf which needs the text PassengerDefaultUser www-dataadded as seen here:

<IfModule mod_passenger.c>
  PassengerDefaultUser www-data
  PassengerRoot /usr
  PassengerRuby /usr/bin/ruby

Now create a symlink to connect Redmine into the web document space:

$ sudo ln -s /usr/share/redmine/public /var/www/redmine

And modify /etc/apache2/sites-available/default to insert the following with the other <Directory> sections so that apache knows to follow the symlink into Rails:

<Directory /var/www/redmine>
    RailsBaseURI /redmine
    PassengerResolveSymlinksInDocumentRoot on

Now restart apache:

$ sudo service apache2 restart

You should now be able to access redmine from the local host

$ firefox

In the upper right corner of the browser window you should see the “Sign in” link. Click that and enter “admin” at both the Login: and Password:prompts. Note: this is not the password you set during the installation process. Click the Login button.

I recommend that the next thing you do is to click on My account in the upper right corner and change that password. In the page that is displayed there should be a Change password link in the upper right of the white area of the page. Click to change the password.

Backing up Redmine

You should arrange a regular backup of the Redmine database and the files that users upload/attach. The database can be dumped to a text file with:

/usr/bin/mysqldump -u root -p<password> redmine_default | gzip > /path/to/backups/redmine_db_`date +%y_%m_%d`.gz

where <password> is the one you set when installing mysql.

The attachments are stashed in /var/lib/redmine/default/files and can be backed up with something like:

rsync -a /var/lib/redmine/default/files /path/to/backups/files

You can have these commands run automatically by creating a script called /etc/cron.daily/redmine that contains:

/usr/bin/mysqldump -u root -p<password> redmine_default | gzip > /path/to/backups/redmine_db_`date +%y_%m_%d`.gz
rsync -a /var/lib/redmine/default/files /path/to/backups/files

Again, be sure to substitute the mysql root password for <password> in the mysqldump command line. The file should be protected so that only root has read permission because you are storing the root password for your mysql installation in this file. That the first line creates a new file every time the script is run. This can eventually create a large number of backups of your database files. You should have a script that purges old ones periodically.

Additional semi-optional packages

There are some services that Redmine can use that are not absolutely necessary, but are useful. These are email and software repository/revision control systems.

Email setup

At some point you will probably want Redmine to be able to send email. For this you will need to install and configure email. This can be achieved by installing the postfix package. I do not recommend the exim4 package, as there have been some incompatibilities in the way the “sendmail” command line is handled between Redmine and exim4. Unless everyone has an email account on the redmine server you will want to set up external email as a full internet host. Once email service is installed, you will have to restart apache for Redmine to know that it has access to email services.

$ sudo apt-get install postfix

Now that you can send email, you have to tell Redmine about it. You need to create/edit the file /etc/redmine/default/configuration.yml and add the following lines:

    delivery_method: :sendmail

Then restart apache so that Redmine reloads the configuration file:

$ sudo service apache2 restart

Revision control repository setup

In order to have your software repository on the system Redmine will need the corresponding software installed.

$ sudo apt-get install git subversion cvs mercurial
$ sudo service apache2 restart

That covers it as far as I have gotten in my use of Redmine to date.

How To Install MongoDB on Ubuntu 12.04

MongoDB is a document database used commonly in modern web applications. This tutorial should help you setup a virtual private server to use as a dedicated MongoDB server for a production application environment.


Step 1 — Create the Install Script

The MongoDB install process is simple enough to be completed with a Bash script. Copy the following into a new file named `mongo_install.bash` in your home directory:

apt-key adv –keyserver keyserver.ubuntu.com –recv 7F0CEB10

echo “deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen” | tee -a /etc/apt/sources.list.d/10gen.list

apt-get -y update

apt-get -y install mongodb-10gen


Here’s an explanation of each line in the script:

The `apt-key` call registers the public key of the custom 10gen MongoDB aptitude repository

A custom 10gen repository list file is created containing the location of the MongoDB binaries

Aptitude is updated so that new packages can be registered locally on the Droplet

Aptitude is told to install MongoDB

TIP: At any time, to change to your home directory, simply execute `cd`


Step 2 — Run the Install Script

Execute the following from your home directory:

$ sudo bash ./mongo_install.bash

If everything is successful, you should see the output contain a PID of the newly started MongoDB process:

mongodb start/running, process 2368


Step 3 — Check It Out

By default with this install method, MongoDB should start automatically when your Droplet is booted. This means that if you need to reboot your Droplet, MongoDB will start right back up.

To start learning about the running `mongod` process, run the following command:

$ ps aux | grep mongo


One line of the output should look like the following:

mongodb 569 0.4 6.4 627676 15936 ? Ssl 22:54 0:02 /usr/bin/mongod –config /etc/mongodb.conf


We can see the…

User: `mongodb`

PID: `569`

Command: `/usr/bin/mongod –config /etc/mongodb.conf`

Config File: `/etc/mongodb.conf`