Step-by-Step Guide to Installing Bolt CMS on Ubuntu 18.04 LTS

Bolt is a sophisticated, lightweight, and simple CMS built with PHP. It is released under the open-source MIT-license, with its source code hosted on a public repository on Github. Bolt is a tool for Content Management, designed to be as simple and straightforward as possible. It is quick to set up, easy to configure, and uses elegant templates. Bolt is created using modern open source libraries and is best suited for building sites in HTML5 with modern markup. This tutorial will guide you through the installation of Bolt CMS on an Ubuntu 18.04 LTS system using Nginx as a web server, MySQL as a database server, and optionally, securing the transport layer using acme.sh client and Let’s Encrypt for SSL support.

Requirements

The system requirements for Bolt are minimal, ensuring compatibility on any reasonably modern web server:

  • PHP version 5.5.9 or higher, with common PHP extensions: pdo, mysqlnd, pgsql, openssl, curl, gd, intl, json, mbstring, opcache, posix, xml, fileinfo, exif, and zip.
  • Access to SQLite (bundled with PHP), or MySQL, or PostgreSQL.
  • Apache with mod_rewrite enabled (.htaccess files) or Nginx (virtual host configuration covered below).
  • A minimum of 32MB of memory allocated to PHP.

Prerequisites

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

Initial Steps

Verify your Ubuntu version:

lsb_release -ds
# Ubuntu 18.04.1 LTS

Configure the timezone:

sudo dpkg-reconfigure tzdata

Update your operating system packages (software) to ensure you have the latest updates and security fixes:

sudo apt update && sudo apt upgrade -y

Install essential packages for the basic administration of the Ubuntu operating system:

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

Step 1 – Install PHP and Necessary PHP Extensions

Install PHP and the required PHP extensions:

sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mbstring php7.2-zip php7.2-pgsql php7.2-sqlite3 php7.2-curl php7.2-gd php7.2-mysql php7.2-intl php7.2-json php7.2-opcache php7.2-xml

Display PHP compiled modules with:

php -m

ctype
curl
exif
fileinfo
. . .
. . .

Check PHP version:

php --version

# PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

The PHP-FPM service is automatically started and enabled on Ubuntu 18.04, so there’s no need to manually start it. Proceed to the next step, which involves the installation and setup of the database.

Step 2 – Install MySQL and Create a Database for Bolt CMS

Bolt CMS supports MySQL, MariaDB, and PostgreSQL databases. In this guide, we’ll use MySQL as the database server.

Install the MySQL database server:

sudo apt install -y mysql-server

Verify the MySQL version:

mysql --version
# mysql  Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using  EditLine wrapper

Run the mysql_secure_installation script to enhance MySQL security and set a password for the MySQL root user:

sudo mysql_secure_installation

Respond to the following prompts:

Would you like to setup VALIDATE PASSWORD plugin? N
New password: your_secure_password
Re-enter new password: your_secure_password
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Connect to the MySQL shell as the root user:

sudo mysql -u root -p
# Enter password

Create an empty MySQL database and user for Bolt CMS, and remember the credentials:

mysql> CREATE DATABASE dbname;
mysql> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;

Exit from MySQL:

mysql> exit

Substitute dbname, username, and password with your custom settings.

Step 3 – Install acme.sh Client and Obtain Let’s Encrypt Certificate (Optional)

While it’s not mandatory to secure your website with HTTPS, it is recommended to enhance site security. To obtain a TLS certificate from Let’s Encrypt, we will employ the acme.sh client, a Unix shell software for acquiring 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 your_email@example.com
source ~/.bashrc
cd ~

Verify acme.sh version:

acme.sh --version
# v2.8.1

Acquire 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

For testing purposes, you can append the --staging flag to the commands above to obtain fake certificates.

Your certificates and keys will be located at:

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

List your issued certs with:

acme.sh --list

Create directories to store your certificates; here, we utilize the /etc/letsencypt directory:

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

Copy/install certificates to the /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 certificates will auto-renew every 60 days.

After obtaining the certificates, exit from the root user and return to the normal sudo user:

exit

Step 4 – Install NGINX and Configure It for Bolt CMS

Bolt CMS is compatible with various popular web server software, but here we choose Nginx. If you opt for Apache, refer to their documentation for more information.

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)

Configure Nginx for Bolt CMS by running:

sudo vim /etc/nginx/sites-available/bolt.conf

Fill the file with the following configuration:

server {
listen 80;
listen 443 ssl http2;
server_name example.com;
root /var/www/bolt/public;
index index.php;

# 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;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location = /bolt {
try_files $uri /index.php?$query_string;
}

location ^~ /bolt/ {
try_files $uri /index.php?$query_string;
}

location ~ /index.php/(.*) {
rewrite ^/index.php/(.*) /$1 permanent;
}

location ~ /\. { deny all; }
location ~ /\.(htaccess|htpasswd)$ { deny all; }
location ~ /\.(?:db)$ { deny all; }
location ~* /(.*)\.(?:markdown|md|twig|yaml|yml)$ { deny all; }

location ~ [^/]\.php(/|$) {
include snippets/fastcgi-php.conf;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTP_PROXY "";
fastcgi_param HTTPS $https if_not_empty;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}

}

NOTE: For a more comprehensive, production-ready Nginx configuration for Bolt CMS, please consult their documentation.

Enable the new bolt.conf configuration by linking it to the sites-enabled directory:

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

Check the Nginx configuration for syntax errors:

sudo nginx -t

Reload the Nginx service:

sudo systemctl reload nginx.service

Step 5 – Install Bolt CMS

Create the /var/www directory:

sudo mkdir -p /var/www/

Navigate to the /var/www directory:

cd /var/www/

Download the most recent Bolt CMS release via wget and unzip it:

sudo wget https://bolt.cm/distribution/bolt-latest.zip && sudo unzip bolt-latest.zip

Remove the downloaded bolt-latest.zip file:

sudo rm bolt-latest.zip

Rename the bolt-v3.6.4 directory to simply bolt:

sudo mv bolt-v3.6.4 bolt

For the installation to complete, rename the following files:

sudo mv .bolt.yml.dist .bolt.yml
sudo mv composer.json.dist composer.json
sudo mv composer.lock.dist composer.lock
sudo mv src/Site/CustomisationExtension.php.dist src/Site/CustomisationExtension.php

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

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

In your browser, navigate to the folder where you uploaded Bolt and follow the on-screen instructions.

Step 6 – Complete the Bolt CMS Installation and Setup

Upon opening your site in a browser, you should be redirected to the following page:

Bolt CMS setup wizard

Enter the necessary information to create a user and click the “Create the first user” button to continue. The Bolt CMS admin interface should then appear:

Bolt CMS dashboard

Bolt CMS installation is now complete. To access the Bolt CMS admin panel, append /bolt to your site’s IP or domain.

Frequently Asked Questions

What is Bolt CMS?

Bolt is a sophisticated, lightweight, and simple CMS built with PHP. It is open-source, easy to set up, and uses modern templating techniques with support for HTML5.

What are the prerequisites for installing Bolt CMS?

You need a system running Ubuntu 18.04 LTS, a non-root user with sudo privileges, and a server environment meeting certain PHP requirements.

Which database systems can I use with Bolt CMS?

Bolt CMS supports MySQL, MariaDB, and PostgreSQL. This guide focuses on using MySQL.

Is it necessary to secure my website with HTTPS?

While not mandatory, securing your website with HTTPS is recommended for enhancing site traffic security.

How can I access the Bolt CMS admin panel?

After installation, access the Bolt CMS admin panel by appending /bolt to your site’s IP or domain.