Grails (grails.org) is an open source web application framework which uses the Groovy programming language, which is based on Java. The official website contains comprehensive installation documentation, but this tends to be biased towards Debian/Ubuntu distros, with Red Hat/CentOS less well documented.
The following details steps taken to install Grails on a CentOS 5.7 64-bit server. If you are installing on a significantly different version, or a 32-bit build, please adjust downloads accordingly.
Before you can install Grails, you need to install the Java JDK.
Move into the build directory and download the bin file:
cd /usr/src/
wget http://download.oracle.com/otn-pub/java/jdk/6u25-b06/jdk-6u25-linux-x64.bin
This will generate a bin file with a large extension of random characters, which will be different each time, e.g. -
jdk-6u25-linux-x64.bin\?e\=1320943362\&h\=4fc7a3cb2942a57fd98dbefa0e086ca2
Turn this into something more usable by running:
mv jdk-6u25-linux-x64.bin jdk-6u25-linux-x64.bin
Then copy (or move if you prefer) it into the java directory:
cp jdk-6u25-linux-x64.bin /usr/java/
And run it:
sh /usr/java/jdk-6u25-linux-x64.bin
This will create a ‘jdk1.6.0_25′ folder in the /usr/java/ directory.
The use your preferred text editor to edit /root/.bash_profile and comment out the existing java path:
# export JAVA_HOME=/usr
And then add:
JAVA_HOME=/usr/java/jdk1.6.0_25
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
Save changes and exit, and the Java JDK installation is complete.
Next, install Grails. In previous installations, we have installed it inside a user’s home directory, so let’s assume a path of ‘/home/test’.
To download, build and then install it, run:
cd /home/test
wget http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/grails-1.3.7.zip
unzip grails-1.3.7.zip
cd grails-1.3.7
./gradlew libs
./gradlew install
Next, open /root/.bashrc in a text editor and add:
export GRAILS_HOME=/home/test/grails-1.3.7
export PATH=${GRAILS_HOME}/bin:${PATH}
To test that it’s working, create a test project by running:
grails create-app YourProject
If everything is working correctly, eventually you should get a message like this:
Created Grails Application at /home/test/YourProject
Next, test the deployment of a WAR file to the project. You must be inside the project folder to do this, so run ‘cd /home/test/YourProject’ first, if not already inside the folder.
Then run:
grails war
If everything is okay, you should eventually see a message like this:
Done creating WAR /home/test/YourProject/target/YourProject-0.1.war
And that’s Grails installed.
Further reading:
*Install guide: http://grails.org/Installation
*Common command line options: http://www.grails.org/Command+Line+Tools