Dancer2 Setup And Project Installation

Posted by Ashutosh on February 08, 2020

Dancer2 is a light-weight web framework in Perl. Dancer2 is simple but extremely powerful to develop complex web applications. It opts for a handful of modules to start developing web projects.

Before starting the Project in Dancer2, the following are the prerequisites for this tutorial:

  1. Perl version 5.24 or greater installed on your local machine. On Unix or Mac Operating System, Perl is available through the default OS installation packages, if you are using the windows machine, install it from here.
  2. Elementary knowledge of Perl (Not Object Oriented) is essential. If you are not accustomed to basic Perl, then you are not ready for this tutorial. I would recommend acquiring fundamental knowledge of Perl first and continue the tutorial.
  3. Basic knowledge of HTML, CSS, Bootstrap(Optional).

Installation of Dancer2

You are over here!!! You fulfilled all the prerequisites to get started with Dancer2 Application. Great!!!

Let’s start with the Dancer2 Installation.

From the Command line terminal,

sudo cpan install Dancer2

This command will install the Dancer2 on your local machine.

Alternate way of installing it on Unix or Unix-like systems:

sudo wget -O - | sudo perl - Dancer2

The previous command will also work on Windows after installing CygWin.

If Operating system is Debian/Ubuntu, Dancer2 is available as repository package.

sudo apt-get install libdancer2-perl

Quick Start Project in Dancer2

From the terminal execute the following:

dancer2 -a PForums

It creates a web Application in dancer2, *PForums* is the name of our Application. Along with the Project Folder, it creates the Skeleton of the Project to develop more Complex Web Application if required.

Typical Dancer2 Project Skeleton looks like:


In Dancer2 framework, one line is enough to create the Project. Isn’t is easy?

Application Launch

Dancer2 is a PSGI web application framework, plackup tool is used for launching the application.

→ Go to the Project Folder (PForums in our case.)

plackup -a bin/app.psgi

Command starts the Web Server at 5000 port. HTTP::Server::PSGI: Accepting connections at http://0:5000/

Go to the browser and launch http://localhost:5000/


Congratulation, you launch your first Dancer2 Web App.

In this tutorial we learn:

  • Dancer2 Introduction
  • Dancer2 Installation
  • Setting-up the Project
  • Launch the web application.