How to Install Play framework on Debian 11

A framework that is not as well known as others but is very versatile to use is Play Framework. Today we will talk about it and learn how to install it on Debian 11.

What is Play Framework?

Play is a framework for creating web applications using the power of Scala and Java. This allows us to have powerful applications and package them quickly.

Built on top of Akka, Play provides predictable and minimal resource consumption (CPU, memory, threads) for highly scalable applications. Contrary to the belief that Java is too heavy, Play allows us to use it without so many problems.

On the other hand, the compiler and runtime (JVM) do the heavy lifting so that your applications run superfast and keep running under load. So, we can get the most out of it.

Install Play Framework

Installing this framework is not as complicated as it sounds. However, we will have to install some tools beforehand to make things easier. Let’s get started.

Install SDK on Debian 11

The first thing we need to do is to access our terminal or via SSH and update the whole system.

sudo apt update
sudo apt upgrade

Next, you have to install some necessary packages.

sudo apt install git unzip zip curl

Next, you can use curl to download the SDK installation script. At once, we will run this script. Then to download and install SDK, just run.

curl -s "https://get.sdkman.io" | bash
Install SDK on Debian 11
Install SDK on Debian 11

To complete the process, run this command after the previous command has finished executing.

source "$HOME/.sdkman/bin/sdkman-init.sh".

Check the changes made by verifying the SDK version installed.

sdk version
Show the SDK version
Show the SDK version

Installing Java and SBT using SDK on Debian 11

Play only supports Java versions 8 and 11. So, we have to choose one of these and for that, we will use SDK.

sdk install java 11.0.14-tem
Install Java with SDK
Install Java with SDK

Java is followed by SBT. To install it using SDK, just run.

sdk install sbt
SBT installed for Play
SBT installed for Play

Download Play Framework examples

To check that we can use Play, we first have to download some examples that will help us to know if everything we have done is OK.

To download it, just clone a file from the GIT repository:

cd ~
git clone https://github.com/playframework/play-samples.git

Access the folder that has been generated

cd play-samples/play-scala-hello-world-tutorial

And you can run the program by

sbt run

Then you can access it from a web browser at the address locahost:9000.

Play framework on Debian 11
Play framework on Debian 11

But if you are doing this test from a virtual machine or a VPS, then you have to enable access to any host. To achieve this, edit the configuration.

nano conf/application.conf

And add the following

play.filters.hosts {
  allowed = ["."]
}

Save the changes and you are done.

This indicates that Play is ready to use.

Create a new project with Play Framework

Now we are ready to create a new project with Play. To achieve this, just create a folder with the name of your project.

cd ~
mkdir project

After accessing it, we will be able to download the Play project template.

cd project
sbt new playframework/play-java-seed.g8

And when we finish, we can start working.

Conclusion

Play Framework combines the power of Java with Scala to make lightweight but scalable, robust web applications.

I hope this post has helped you, and you can share it with others.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top