Install Automad CMS with Nginx and Let's Encrypt SSL on Ubuntu 18.04

Automad is an open-source file-based content management system (CMS) and a template engine written in PHP. All content is stored in human-readable text files instead of a database. An Automad site is therefore fully portable, easy to install, and can be version controlled by using Git or Mercurial. It nevertheless offers database features like searching and tagging. The built-in template engine allows even inexperienced developers and designers to create beautiful themes and templates. In this tutorial, we will go through the Automad CMS installation and setup on Ubuntu 18.04 LTS system by using NGINX as a web server.

Requirements

Requirements for installing and running Automad CMS are as follows:

  • PHP version 5.4 or higher.
  • Web server software like Nginx or Apache.

Prerequisites

  • An Ubuntu 18.04 LTS operating system.
  • A non-root user with sudo privileges.

Initial steps

Check your Ubuntu version:

lsb_release -ds
# Ubuntu 18.04.2 LTS

Set up the timezone:

sudo dpkg-reconfigure tzdata

Update your operating system packages (software). That is an essential first step because it ensures you have the latest updates and security fixes for your operating system's default software packages:

sudo apt update && sudo apt upgrade -y

Install some essential packages that are necessary for basic administration of Ubuntu operating system:

sudo apt install -y curl wget vim git unzip socat bash-completion apt-transport-https

Step 1 - Install PHP and necessary PHP extensions

Install PHP, as well as the required PHP extensions:

sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-curl php7.2-zip

To show PHP compiled in modules, you can run:

php -m

ctype
curl
exif
fileinfo
. . .
. . .

Check the version:

php --version

# PHP 7.2.19-0ubuntu0.18.04.1 (cli) (built: Jun 4 2019 14:48:12) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.2.19-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

PHP-FPM service is automatically started and enabled on reboot on Ubuntu 18.04 system, so there is no need to start and enable it manually. We can move on to the next step.

Step 2 - Install acme.sh client and obtain Let's Encrypt certificate ( optional )

Securing your forum with HTTPS is not necessary, but it is a good practice to secure your site traffic. To obtain a TLS certificate from Let's Encrypt we will use acme.sh client. Acme.sh is a simple UNIX shell software for obtaining TLS certificates from Let's Encrypt with zero dependencies.

Download and install acme.sh:

sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
./acme.sh --install --accountemail [email protected]
source ~/.bashrc
cd ~

Check acme.sh version:

acme.sh --version
# v2.8.0

Obtain RSA and ECC/ECDSA certificates for your domain/hostname:

# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256

If you want fake certificates for testing, you can add --staging flag to the above commands.

After running the above commands, your certificates and keys will be in:

  • For RSA: /home/username/example.com directory.
  • For ECC/ECDSA: /home/username/example.com_ecc directory.

To list your issued certs you can run:

acme.sh --list

Create a directory to store your certs. We will use /etc/letsencrypt directory.

mkdir -p /etc/letsecnrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc

Install/copy certificates to /etc/letsencrypt directory.

# RSA
acme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA
acme.sh --install-cert -d example.com --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"

All the certificates will be automatically renewed every 60 days.

After obtaining certs exit from root user and return to regular sudo user:

exit

Step 3 - Install and configure NGINX

Download and install NGINX from the Ubuntu repository:

sudo apt install -y nginx

Check the NGINX version:

sudo nginx -v
# nginx version: nginx/1.14.0 (Ubuntu)

Run sudo vim /etc/nginx/sites-available/automad.conf and populate the file with the following configuration:

server {

  listen [::]:443 ssl http2;
listen 443 ssl http2;
listen [::]:80;
listen 80;
# RSA
ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com/private.key;
# ECC
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
server_name example.com; root /var/www/automad; index index.php index.html; client_max_body_size 100M; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { fastcgi_index index.php; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }

Activate the new automad.conf configuration by linking the file to the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/automad.conf /etc/nginx/sites-enabled/

Check NGINX configuration for syntax errors:

sudo nginx -t

Reload Nginx:

sudo systemctl reload nginx.service

Step 4 - Install Automad CMS

Create a document root directory for Automad:

sudo mkdir -p /var/www/automad

Navigate to the document root:

cd /var/www/automad

Using curl download the latest release of Automad CMS. Don't forget to bump up the version numbers if there is a newer release:

sudo curl -O -J -L https://automad.org/download

Uncompress the zip archive:

sudo unzip marcantondahmen-automad-6fff2a0456dc.zip

Move all Automad files to the document root and remove downloaded zip archive:

sudo mv marcantondahmen-automad-6fff2a0456dc/* . && sudo mv marcantondahmen-automad-6fff2a0456dc/.* .
sudo rm marcantondahmen-automad-6fff2a0456dc.zip
sudo rmdir marcantondahmen-automad-6fff2a0456dc

Change ownership of the /var/www/automad directory to www-data:

sudo chown -R www-data:www-data /var/www/automad

Step 5 - Finish the Automad installation

As the last step, create a user account to use the browser-based user interface called the Dashboard. Therefore navigate to https://example.com/dashboard and follow the instructions.

Before you can use Automad dashboard, you will need to create an account:

Create website in Automad

Create a user account using the form and download the generated file to your computer. After you will need to move the downloaded file to the "/config" directory within Automad installation directory.

After that you can log in to Automad dashboard:

Automad Log in

In the end, Automad admin interface will be displayed:

Automad admin dashboard

That's it. Automad installation is finished.

Links

Share this page:

0 Comment(s)