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.
Grails is an open-source web development framework, based on the Groovy programming language (which runs on the Java platform).
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.
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:
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.
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
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.
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.Sign up