Lift Tutorial 2: Nice Server with Jetty and MongoDB

What this tutorial will cover

EC2 instance

Jetty

MongoDB

Screen (to have both Jetty and MongoDB running in the background and see the output)

Easy deployment script (SCP)

EC2 instance

I just got a free micro EC2 instance at AWS (Amazon Web Services) for 1 year for free (see here) and thought I could try out Scala and Lift on it. I did that once already to test, but this time I wanted a nicer installation. I wanted to use Jetty as Server that is always running on the ec2 instance. Then I want to be able to easily deploy .war files to it.

If you are on windows and you want to connect to your EC2 with Putty follow the instructions here.

Jetty

To get a basic jetty version running on your server, do the following:

There you go. Your basic jetty installation is running already! Put a .war file into the webapps folder and access it by adding the name of the war file to the url (filename.war => http://server.com/filename/ )

Try screen -S jetty and then start Jetty there. To leave that “screen” press CTRL A + D. To see that screen again enter screen -r jetty. You can do the same with another name for MongoDB, just use mongodb instead of jetty in the command.

Easy deployment script (SCP)

Sometimes typing sbt package and scp ... can be too much. :D So I wrote a small script that does the work for you. Create a file called deploy in the root of the sbt project, adjust the values below SETTINGS and make chmod +x deploy. After that you can run it with ./deploy. Have fun :)