This guide is intended for self hosters, looking for a step-by-step guide to getting Letterpad installed, setup and configured on their own servers
If you're looking to install Letterpad on your local machine, perhaps just to test it out or to develop a theme, please follow the local install guide instead.
Create A Non-root User
We will create a new user, letterpad, with sudo access as its not advised to do everything as the root user:
Follow the prompts to set the new user’s name and password. You can leave all the other fields blank by hitting Enter.
Now let’s add the new user to two groups:
gpasswd -a letterpad sudo gpasswd -a letterpad www-data
This gives the
letterpad user administrative access and adds it to the same group as Nginx, which we'll get to later.
First, let’s run system updates:
sudo apt-get update && sudo apt-get upgrade -y
Now let’s install git, nodejs and nginx server:
Letterpad requires min Node v8.10.0+, but we will install the latest one directly from the NodeSource repo:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt-get install -y nodejs
Install yarn. We will use yarn instead of npm to manage dependencies.
sudo curl -o- -L https://yarnpkg.com/install.sh | bash
Since we’re installing with the beta version of Letterpad, we need to build it from the source. Let’s start by cloning the repo from GitHub:
cd /var/www sudo git clone https://github.com/letterpad/letterpad.git sudo chown -R $USER:www-data /var/www/letterpad cd letterpad
This will create
/var/www/letterpad and copy the source from GitHub.
Next we need to create the
.env file. This file contains important settings that Letterpad needs to run. We can use the existing
sample.env provided by letterpad as a template, so let's copy it to
.env and open it for editing:
cp sample.env .env nano .env
If you have a domain, change the value of rootUrl to
http://[your-domain].com/. If not, use
http://<droplet-ip>/ for now — you can change it later on if you add a domain.
You also need to change the apiUrl and uploadUrl. Replace http://localhost:3030 to the same value which you did in the last step. If you have used the dropletIp, your file will look something like below:
If you’re using a domain, make sure you’ve configured your DNS properly and allowed enough time for it to resolve (usually up to 24 hours).
SECRET_KEY to a random string. Just make sure it's reasonably long and random.
Lastly, update the SMTP section. This section is important, otherwise you won’t be able to create users, reset passwords, etc. If you don’t already have a transactional email service, you may use your gmail credentials to configure this.
Now save the file by pressing
ctrl + x, y, enter.
The last step is to install required modules through yarn.
Now we need to configure Nginx to act as a reverse proxy for our letterpad. All the traffic will first hit this nginx server and then nginx server will route this to your nodejs server where letterpad is running.
Let’s replace the default config with a custom one:
sudo nano /etc/nginx/sites-available/default
Delete everything and paste the following:
Make sure to change
yourdomain.com to the same domain or IP address you used in the
Save and exit by pressing
ctrl + x, y, enter.
Now test the config and restart Nginx:
sudo nginx -t sudo systemctl restart nginx
We will use — production=false as an argument to install the devDependencies as well for building optimised letterpad bundles.
yarn install --production=false
Before starting letterpad, we have to create the optimized bundles. We can do so by entering the below command in your terminal.
theme=hugo yarn build
This will build the letterpad engine as well the theme hugo.
Once that is done, we will run the below command to turn on letterpad.
If everything is setup properly, you’ll be able to access Letterpad from the URL or IP address you entered in the last step.
To run any nodeJS application continiously, we will need a task runner like pm2 to launch and monitor the app. If Letterpad crashes, pm2 will restart it. If your droplet gets restarted, pm2 will make sure Letterpad relaunches on startup.
yarn global add pm2 yarn prodPm2 sudo pm2 startup systemd
If you encounter any issues with the above article, drop a comment and we will try to fix it together.