# How can I quickly set up Primero

**URL:** <https://support.primero.org/forum/t/how-can-i-quickly-set-up-primero/183>\
**Category:** Primero IMS\
**Tags:** v1-7, v1-6, v1-4, v1-5\
**Created:** [March 14, 2019, 5:56pm UTC](https://support.primero.org/forum/t/how-can-i-quickly-set-up-primero/183 "2019-03-14T17:56:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [March 14, 2019, 5:56pm UTC](https://support.primero.org/forum/t/how-can-i-quickly-set-up-primero/183/1 "2019-03-14T17:56:34Z")

</div>

Here is a quick overview of the steps required to set up Primero on a linode server using Chef. It is structured into tasks to be completed on the Linode virtiual machine and then tasks to be completed on a local machine (like a laptop)

Each section will be explained in detail.

## Overview of Linode Tasks (from now on this will be referred to as the `target` machine)

- Log in to Linode and set up a small virtual machine (recommended is a 4GB instance) running Ubuntu 16.04 LTS. ![image](https://support.primero.org/uploads/primero/original/1X/3abc7ae8f53676d3d938d51691926a9a88ef97e1.png)
- Create a user on the target machine with passwordless sudo access
- Set up DNS so that a domain name resolves to the target machine
- Install a digital certificate based on the domain name using the certbot application created by Lets Encrypt. If you use the `"recipe[primero::letsencrypt]",` in your json configuration (explained later) then chef will do this for you

## Overview of Local Tasks (from now on this will be referred to as the `deployment` machine)

- Install Chef and Knife
- Clone the Primero repository and make sure your public SSH key has been added to the github repository
- Create a configuration file for Chef and run the config file using chef

# Tasks on the `target` machine

## Log in to Linode and set up a linode running Ubuntu 16.04 LTS.

- Create a linode using the web interface  
\_ Note that the version of Ubuntu is important\_

After that completes note the SSH access details (like `ssh root@xxx.xxx.xxx.xxx` ) on the Linodes tab in the Linode interface.

## Create a user on the target machine with passwordless sudo access

- Using a Terminal log in using the SSH details noted above. Create a new user

```auto
root@machine:~# adduser <user>

```

Give this new user access to sudo

```auto
root@machine:~# adduser <user> sudo

```

## Set up DNS so that a domain name resolves to the `target` machine

- Add a Domain Zone on Linode.

The IP address if the machine you just set up must point tot the domain and the nameservers also need to resolve

 ![image](https://support.primero.org/uploads/primero/original/1X/240097dd549541ea9ed7e80ef373de9dc6bcaaa0.png)

# Tasks on the `deployment` machine

## Copy your ssh ID to the `target` machine

ssh-copy-id @xxx.xxx.xx.xxx

## Install Chef and Knife

Open a terminal and do

```sh
$ wget https://packages.chef.io/stable/debian/6/chefdk_0.9.0-1_amd64.deb
$ sudo dpkg -i chefdk_0.9.0-1_amd64.deb
$ chef verify
$ chef gem install knife-solo --version 0.4.3

```

_Note that the version number of chef is important_

## Clone the Primero repository and make sure your public SSH key has been added to the repository

Copy your public ssh key using

`$ pbcopy < ~/.ssh/id_rsa.pub`

and paste it into the ssh keys on github. Then clone the repository using

`$ git clone https://github.com/primeroIMS/primero.git`

## Create a configuration file for Chef and run the config file using chef

In the cookbook folder of the checkout there is a file called `dev_node.json` which is an example configuration file for chef. Paste appropriate certificates and keys for couchdb and the deploy key  
Here we are deploying the maint\_1.6 branch with unattended upgrades and a lets encrypt certificate. These are called recipies (there are others available)

```auto
{
  "couch_db": {
    "config": {
      "httpd": {
        "bind_address": "0.0.0.0"
      }
    }
  },
  "primero": {
    "environment": "dev",
    "rails_env": "production",
    "server_hostname": "somehost.com",
    "no_reseed": false,
    "git": {
      "repo": "<your git repo>",
      "revision": "maint_1.6"
    },
    "letsencrypt": {
      "email": "your@email.com",
      "couchdb": true
    },
    "couchdb": {
      "password": "",
      "ssl": {
        "cert": "",
      "key": ""
      }
    },
    "deploy_key": "",
    "ssl": {
      "crt": "",
      "key": ""
    }
  },
  "unattended-upgrades": {
    "send_email": true,
    "email_address": "primero_support@your.org",
    "auto_reboot": true
  },
  "run_list": [ 
    "recipe[primero::default]",
    "recipe[primero::letsencrypt]", 
    "recipe[chef-unattended-upgrades::default]" 
  ]
}

```

Make sure you copy the certificates exactly (without spaces for example). A useful command is this for example

`awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' couch_ca.cert`

After this is done run the deployment command (from the cookbook folder)

`ssh user@xx.xx.xx.x 'which chef-solo' || knife solo prepare --bootstrap-version=11.10.4 user@xx.xx.xx.xx`

```
knife solo cook user@xx.xx.xx.xx dev-node.json

```

_Note that if you want to deploy a branch which is not the latest this is (maint\_1.6 at the time of writing) then you need to run chef from the branch you want to deploy. For example this is for the 1.5 release_

`git checkout --track maint_1.5/maint_1.5`

and then

`knife solo cook user@xx.xx.xx.xx dev-node.json`

---

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [May 9, 2019, 5:42pm UTC](https://support.primero.org/forum/t/how-can-i-quickly-set-up-primero/183/3 "2019-05-09T17:42:02Z")

</div>



---

<div class="post-metadata">

**Author:** ![Sam](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@Sam](https://support.primero.org/forum/u/Sam)\
**Post date:** [July 21, 2019, 6:02pm UTC](https://support.primero.org/forum/t/how-can-i-quickly-set-up-primero/183/4 "2019-07-21T18:02:25Z")

</div>

Hey @irlawrence …this post helped me a lot to deploy my production setup for primero. Thank you soo much for covering such small details.  
If possible could you please tell me what I could do to change logo of primero etc after deploying the production setup on the server.  
Thanks in advance. Any kind of help is appreciated.

---

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [July 23, 2019, 12:26pm UTC](https://support.primero.org/forum/t/how-can-i-quickly-set-up-primero/183/5 "2019-07-23T12:26:32Z")

</div>

The best way to add a logo is to log in as a super user and then edit the agency screen in settings

 ![image](https://support.primero.org/uploads/primero/original/1X/5efe22c910e2e7623a00c2370c7ec527f76f65ef.png)  
If you wish to change the main primero logo then you need to create (or use an existing) rake task for that and also recompile the assets. See [here](https://support.primero.org/forum/t/adding-a-logo-or-changing-the-colour-of-primero/163/4) for the details

---

<div class="post-metadata">

**Author:** ![omgalvan.86](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/e8c25b/32.png) [@omgalvan.86](https://support.primero.org/forum/u/omgalvan.86)\
**Post date:** [February 9, 2020, 3:31pm UTC](https://support.primero.org/forum/t/how-can-i-quickly-set-up-primero/183/6 "2020-02-09T15:31:40Z")

</div>

Hey, thanks for the guide. I have a question, though: if I’m adding `recipe[primero::letsencrypt]` to the runlist and setting `primero.letsencrypt.couchdb` to `true`, do I still need to add the SSL certs for the app and CouchDB to dev-node.json? If I understood correctly, the `letsencrypt` recipe will automatically generate Let’s Encrypt certs and use them for both things.

The reason I’m asking is that I left those fields empty, and now the `nginx_common` recipe is failing with the following error:

```auto
 nginx: [emerg] PEM_read_bio_X509_AUX("/etc/nginx/ssl/primero.crt") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: TRUSTED CERTIFICATE)

```

Inspecting /etc/nginx/ssl/primero.crt shows it to be empty. Writing garbage values on those fields results on /etc/nginx/ssl/primero.crt and /etc/ssl/couch.crt having that same garbage, too.

---

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [February 10, 2020, 12:25pm UTC](https://support.primero.org/forum/t/how-can-i-quickly-set-up-primero/183/7 "2020-02-10T12:25:35Z")

</div>

Hi @omgalvan.86,

Your couchdb section in the json should be like this

“couchdb”: {  
“password”: “\<your\_password\>”,  
“ssl”: {  
“cert”: “\<add\_your\_cert\_here\>”,  
“key”: “\<add\_your\_private\_key\_here\>”  
}  
},  
You can create the couchdb cert yourself using [this guide](https://docs.bitnami.com/aws/infrastructure/couchdb/administration/create-ssl-certificate-couchdb/)  
Also I now set nginx default site to be false in the json

` "nginx_default_site": false,`

HTH

---

<div class="post-metadata">

**Author:** ![omgalvan.86](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/e8c25b/32.png) [@omgalvan.86](https://support.primero.org/forum/u/omgalvan.86)\
**Post date:** [February 10, 2020, 2:16pm UTC](https://support.primero.org/forum/t/how-can-i-quickly-set-up-primero/183/8 "2020-02-10T14:16:50Z")

</div>

Yeah, that’s not really what I asked. Nevermind, I already understood that the `primero::letsencrypt` recipe won’t generate the certs by itself. Thanks I guess.
