Minimum Server Setup : Apache, Tomcat & Greenfield on Ubuntu 14.04 for only $7 a month

This tutorial assumes that you have created a VPS instance running Ubuntu 14.04. If you haven't done this yet, read Create Vultr VPS Instance Tutorial. You can be up in running with a VPS instance for as little as $5 a month.

This tutorial will walk you through the steps required to run Greenfield on a production level Ubuntu Web Server running Apache, Tomcat & Greenfield for around $5 to $10 a month depending on your VPS (virtual private server) provider. This tutorial is meant for users who have configured and built Greenfield to run using the H2 in memory database provided by grails. If you have configured Greenfield to run against PostgreSQL, follow these instructions for the minimum server setup, then read Installing & Configuring Postgres on Ubuntu 14.04.

Total Time 15 Minutes

Software Packages to be installed

1. Create VPS Instance running Ubuntu 14.04 LTS

There are many VPS (Virtual Private Server) providers available. I have narrowed down the list to 3 value options. The 3 options include Vultr, Digital Ocean and Linode. If you haven't already done so, you can follow the tutorial below to create a VPS instance on Vultr.

Create Vultr VPS Instance Tutorial

2. Create greenfield User with sudo access

You should now have a VPS instance that you can SSH onto. This next step we will create a new user and give the user sudo access. This user will be used to install and configure all necessary software packages.

SSH to new VPS instance

You should have a new instance that you can now work with.

ssh root@{{server ip address}}

Create User

It is recommended to create a new user for all install & configuration activities, so we will create a new user specifically for this Greenfield tutorial

adduser greenfield

Add greenfield user to sudo group

We now want to give the greenfield user admin priveledges by adding the account to the sudo group

gpasswd -a greenfield sudo

3. Add public key to greenfield user's authorized_keys file

Switch to greenfield user

su - greenfield

Make .ssh directory and change permissions

You will need to be in greenfield's home directory

mkdir .ssh
chmod 700 .ssh

Create authorized_keys file, paste your public key in authorized_keys file

vi .ssh/authorized_keys

Save file

4. Install Latest Java

Update Package list

sudo apt-get update

Install Java

sudo apt-get install default-jdk

5. Install vim (optional)

Purely a preference as I sometimes run into trouble with using vi

Install vim

sudo apt-get install vim

6. Install Apache

Install Apache

sudo apt-get install apache2

Verify Apache installed and running

You should be able to browse to http://{{server ip address}}:80

7. Install & Configure Tomcat

Next we will install and configure Tomcat so we can manage our Greenfield application

Create tomcat directory and cd into it

sudo mkdir /usr/local/tomcat
cd /usr/local/tomcat

Download latest package

This tutorial we will download version v9.0.0.M21

sudo wget

Unpack downloaded tar

sudo tar -xvf apache-tomcat-9.0.0.M21.tar.gz

Create sym-link to unpacked tomcat

sudo ln -s apache-tomcat-9.0.0.M21 tomcat-current

Remove old tar package

sudo rm apache-tomcat-9.0.0.M21.tar.gz

Add CATALINA_HOME & JAVA_HOME to greenfield user's .bashrc.

vi ~/.bashrc

Add following lines to .bashrc

export PATH=/usr/local/bin:$PATH

export JAVA_HOME=/usr/lib/jvm/default-java
export PATH=$JAVA_HOME/bin:$PATH

export CATALINA_HOME=/usr/local/tomcat/tomcat-current						

Source/reload greenfield's .bashrc

source ~/.bashrc

Configure Tomcat Manager app

This step is optional, you can manually deploy Greenfield by simply copying greenfield.war into the $CATALINA_HOME/webapps/ directory (/usr/local/tomcat/tomcat-current/webapps), otherwise edit the tomcat-users.xml file

sudo vim $CATALINA_HOME/conf/tomcat-users.xml

Uncomment the following section and add the manager role in the conf/tomcat-users.xml.

	<role rolename="manager-gui"/>
	<role rolename="tomcat"/>
	<role rolename="role1"/>
	<user username="tomcat" password="tomcat" roles="tomcat,manager-gui"/>
	<user username="both" password="tomcat" roles="tomcat,role1"/>
	<user username="role1" password="tomcat" roles="role1"/>

Save file

Start Tomcat

sudo $CATALINA_HOME/bin/

Verify Tomcat is running

Browse to http://{{server ip address}}:8080

Verify that you can log into Tomcat Manager application

Browse to http://{{server ip address}}:8080. Click Manager App

Login using tomcat for username, tomcat for passowrd.

You will want to change the default password for tomcat, just edit the tomcat-users.xml file, updating the password for tomcat user.

8. Deploy Greenfield Application

Two ways to deploy Greenfield

1. Simply scp the greenfield.war package onto your server, then copy the war file to $CATALINA_HOME/webapps directory. If Tomcat is running, the application will automatically be deployed.

2. The other option is to browse to the Tomcat Manager application, http://{{server ip address}}:8080/manager/html. There is an option 3/4 down the page that reads WAR file to deploy. Select your greenfield.war application on your machine and click Deploy. It will take a few minutes to upload & deploy

Start Greenfield application

You may need to start the Greenfield application after the greenfield.war has been deployed. This can be done in the Tomcat Manager application.

1. Browse to Tomcat Manager application
http://{{server ip address}}:8080/manager/html

2. Click List Applications.

3. Click Start next to the greenfield application listing.

Verify Greenfield is Deployed & Running

Browse to http://{{server ip address}}:8080/greenfield

If everything is setup correctly, you should see a mock store front with no Products or Catalogs available. To add products, add catalogs, change layout, etc., you can access the administration section. Browse to

http://{{server ip address}}:8080/greenfield/admin

Default username admin, password admin. You can change the default password in the administration section under Account menu option

Adding Tomcat to Server restart routine (optional)

Following the next steps will add Tomcat to the list of applications to restart during a system reboot. (Reference Question)

Create tomcat script in /etc/init.d directory

sudo vim /etc/init.d/tomcat

Paste following code in script file and save


# Provides:        tomcat
# Required-Start:  $network
# Required-Stop:   $network
# Default-Start:   2 3 4 5
# Default-Stop:    0 1 6
# Short-Description: Start/Stop Tomcat server


start() {
 sh /usr/local/tomcat/tomcat-current/bin/

stop() {
 sh /usr/local/tomcat/tomcat-current/bin/

case $1 in
  start|stop) $1;;
  restart) stop; start;;
  *) echo "Run as $0 "; exit 1;;

Change the permissions

sudo chmod 755 /etc/init.d/tomcat

Add the symlinks automatically

sudo update-rc.d tomcat defaults

Next Steps

Now that you have minimum packages installed to run Greenfield, you can decide to run Greenfield against a RDBMS like PostgreSQL.

In addition, you are now ready to point your domain at the server and configure the server to map your new website domain to the Greenfield application running in Tomcat. Please read Configuring Domain, Apache + Tomcat + mod_jk + mod_rewrite on Ubuntu 14.04 for instructions on how to do this.