How To Install Grails on an Ubuntu 12.04 VPS

Published on September 30, 2013

Harel Davidov

How To Install Grails on an Ubuntu 12.04 VPS

Status: Deprecated

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

See Instead: This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.

About Grails

Grails is an open-source web development framework, based on the Groovy programming language (which runs on the Java platform).

Step One: Install JDK

Log in into your VPS (droplet), preferably via SSH. (You can follow this tutorial on how to configure SSH on your Droplet.) Then, in order to install OpenJDK, run the following command in the terminal:

sudo apt-get install openjdk-6-jdk

(We’ll install version 6 of the OpenJDK for maximum compatibility with Grails.)

Then, the terminal will ask you for your root password. Enter it and confirm your installation by typing y. Then, the JDK will begin downloading and installing.

Step Two: Install GVM (Groovy enVironment Manager)

GVM is a command-line tool for managing parallel version of different SDKs on Unix-based systems. You can even install multiple version of Groovy or Grails and switch between them very easily.

Before installing GVM, we need to install cURL on our system. Run:

sudo apt-get install curl

(Of course, type ‘y’ to confirm the installation.)

Now that we have cURL installed, we can go and install GVM. In the bash terminal, execute the following command:

curl -s get.gvmtool.net | bash

When the installation ends, it will ask you to open a new terminal or type in a certain command. Type the command the installer gives you. It should be something like: source "/home/username/.gvm/bin/gvm-init.sh"

Step Three: Install Grails

Run the following command in order to install the latest Grails version currently available:

gvm install grails

(If you want to install a specific version of Grails, just add it in the line. For example: gvm install grails 2.2.0)

After the installation finishes, it will ask you whether you want to set this version as the default one. You should enter y to confirm.

Step Four: Test Your Installation

It’s good practice to test if everything was installed as expected, so go ahead an create a new Grails project.

Run the following commands to create a new directory and a new application inside this directory.

mkdir projects
cd projects
grails create-app test

Then, enter the newly-created project directory and run it:

cd test
grails run-app

(The grails run-app command is intelligent enough to know which application to run that’s in the directory you’re in.)

Note: It will install a couple of things before first running an application, so just wait until it’s done.

Browse to http://DROPLET_IP:8080/test and you should be seeing the default Grails application.

You have successfully installed Grails for your development environment!

Note that the run-app command we used here should only be used in the development environment, as it doesn’t scale well in production (and shouldn’t). Real-world production deployments are done as WAR files and are executed by Apache Tomcat, for example. This files have many optimizations in them that aren’t available in the run-app command.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar
Harel Davidov


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

sdkman download address should be; curl -s “https://get.sdkman.io” | bash

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel