How to install Yesod Web Framework

Rômulo Garofalo
2 min readNov 23, 2018

--

# Installation

The first requirement is the Haskell Tool Stack and have cURL or Wget to install (cURL and Wget are tools that install the stack for you)

Let’s open the terminal and paste some commands

You can install the stack in two different ways: the first one is using cURL

$ curl -sSL https://get.haskellstack.org/ | sh

Or you can install with wget

$ wget -qO- https://get.haskellstack.org/ | sh

You can create your project from a stack template

$ stack new learn-yesod yesod-postgres

We should compile the project, but first we need to install the database dependencies that we’re going to use

$ sudo apt-get install libpq-dev

Enter in the folder of the project

$ cd learn-yesod

Run the command to build the template (to compile)

$ stack build

Now wait until all of the 193 dependencies are finished downloading. It should take a while, you can get yourself some coffee.

We have our project ready to start, but we need to connect the database before running the server. You should do so because the server will try to make migrations and without the database it will throw an error at your face

Lets install the postgresql

$ sudo apt-get install postgresql postgresql-contrib

Enter the prompt of the database

$ sudo -u postgres psql

Create a user with root privileges

CREATE USER root WITH SUPERUSER PASSWORD 'root';

And create the database

CREATE DATABASE learn_yesod;

We finished our database configuration, now lets exit the database prompt

\q

Change in the file ‘config/setting.yml’ the config of the database, like in the image

Finally we can run the project with the command

stack exec learn-yesod

When you run the command your terminal will be locked like this:

Now enter in “localhost:3000” on your browser and your site will be there :)

--

--