How to Install Cachet Status Page System on FreeBSD 12
On this page
- Requirements
- Prerequisites
- Step 1 - Install PHP and required PHP extensions
- Step 2 - Install MariaDB and create a database for Cachet
- Step 3 - Install
acme.sh
client and obtain Let">) - Step 4 - Install NGINX and configure NGINX for Matomo
- Step 5 - Install Composer
- Step 6 - Install Cachet
- Step 7 - Complete the Cachet setup
- Links
Cachet is a beautiful and powerful open-source status page system written in PHP that allows you to better communicate downtime and system failures to your customers, teams, and shareholders. The application offers many features, the most important of which are: a powerful JSON API, event reports, metrics, transcription support for event messages, subscriber notifications via email, two-factor authentication. In this tutorial, we will install the Cachet status page system using PHP, Nginx, MariaDB, and Composer on the FreeBSD 12 system.
Requirements
To run Cachet on your FreeBSD 12 system you will need a couple of things:
- PHP version 7.1 or greater
- HTTP server with PHP support (eg: Nginx, Apache, Caddy). This tutorial will use Nginx.
- Composer
- A supported database: MySQL/MariaDB, PostgreSQL or SQLite. This tutorial will use MariaDB.
- Git
- Acme.sh
Prerequisites
- A FreeBSD 12 operating system.
- A non-root user with sudo privileges.
Initial steps
Check your FreeBSD version:
uname -ro
# FreeBSD 12.0-RELEASE
Set up the timezone:
tzsetup
Update your operating system packages (software). This is an important first step because it ensures you have the latest updates and security fixes for your operating system's default software packages:
freebsd-update fetch install
pkg update && pkg upgrade -y
Install some essential packages that are necessary for basic administration of FreeBSD 12.0 operating system:
pkg install -y sudo vim unzip wget bash
Step 1 - Install PHP and required PHP extensions
Install PHP, as well as the necessary PHP extensions:
sudo pkg install -y php72 php72-ctype php72-curl php72-dom php72-hash php72-iconv php72-gd php72-json php72-mbstring php72-openssl php72-session php72-simplexml php72-xml php72-zip php72-zlib php72-pdo php72-pdo_mysql php72-mysqli php72-pgsql php72-sqlite3 php72-filter php72-ftp php72-tokenizer php72-calendar php72-pecl-APCu php72-opcache php72-pecl-redis php72-phar php72-fileinfo
Check the PHP version:
php --version
# PHP 7.2.7 (cli) (built: Jul 25 2019 01:28:53) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.3.7, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.3.7, Copyright (c) 1999-2018, by Zend Technologies
Enable and start PHP-FPM service:
sudo sysrc php_fpm_enable=yes
sudo service php-fpm start
We can move on to the next step, which is obtaining free SSL certs from Let's Encrypt CA.
Step 2 - Install MariaDB and create a database for Cachet
Cachet supports MySQL, MariaDB, PostgreSQL and SQLite databases. In this tutorial, we will use MariaDB as the database server.
Install MariaDB database server:
sudo pkg install -y mariadb102-client mariadb102-server
Check the MariaDB version:
mysql --version
# mysql Ver 15.1 Distrib 10.2.17-MariaDB, for FreeBSD11.2 (amd64) using readline 5.1
Enable and start MariaDB service:
sudo sysrc mysql_enable="yes"
sudo service mysql-server start
Run mysql_secure installation
script to improve MariaDB security and set the password for MariaDB root
user:
sudo mysql_secure_installation
Answer each of the questions:
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 MariaDB shell as the root user:
sudo mysql -u root -p
# Enter password
Create an empty MariaDB database and user for Cachet and remember the credentials:
CREATE DATABASE dbname;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Replace dbname
, username
and password
with your names.
Exit from MariaDB:
exit
Step 3 - Install acme.sh
client and obtain Let's Encrypt certificate (optional)
Securing your website 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 pure 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 the /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 normal sudo user:
exit
Step 4 - Install NGINX and configure NGINX for Matomo
Cachet can work fine with many web servers. In this tutorial, we selected NGINX. If you prefer Apache web server over NGINX, visit https://docs.cachethq.io/docs/installing-cachet#section-running-cachet-on-apache to learn more.
Download and install the latest mainline release of Nginx from the FreeBSD repository:
sudo pkg install -y nginx-devel
Check the Nginx version:
nginx -v
# nginx version: nginx/1.17.2
Enable and start Nginx:
sudo sysrc nginx_enable=yes
sudo service nginx start
Configure Nginx for Cachet by running:
sudo vim /usr/local/etc/nginx/cachet.conf
And populate the file with the following configuration:
upstream php {
server 127.0.0.1:9000;
}
server {
listen [::]:443 ssl;
listen 443 ssl;
listen [::]:80;
listen 80;
server_name example.com;
root /usr/local/www/cachet/public;
index index.php;
# RSA
ssl_certificate /etc/letsencrypt/example.com/fullchain.cer;;
ssl_certificate_key /etc/letsencrypt/example.com/example.com.key;
# ECDSA
ssl_certificate /etc/letsencrypt/sexample.com_ecc/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/example.com.key;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_keep_conn on;
}
}
Run sudo vim /usr/local/etc/nginx/nginx.conf
and add the below line to http {}
block to include Cachet config.
include cachet.conf;
Check Nginx configuration for syntax errors:
sudo nginx -t
Reload Nginx service:
sudo service nginx reload
Step 5 - Install Composer
Install Composer, the PHP dependency manager globally:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
Check Composer version:
composer --version
# Composer version 1.9.0 2019-02-11 10:52:10
Step 6 - Install Cachet
Create a document root directory where Cachet should reside in:
sudo mkdir -p /usr/local/www/cachet
Change ownership of the /usr/local/www/cachet
directory to your_user
:
sudo chown -R your_user:your_user /usr/local/www/cachet
NOTE: Replace jour_user
with your initially created non-root user username.
Navigate to the document root directory:
cd /usr/local/www/cachet
Download the Cachet source code with Git:
git clone -b 2.4 --single-branch https://github.com/cachethq/Cachet.git .
Copy .env.example
to .env
file and configure database and APP_URL
settings in .env
file:
cp .env.example .env
vim .env
Install Cachet dependencies with Composer:
composer install --no-dev -o
Set up the application key by running:
php artisan key:generate
Install Cachet:
php artisan cachet:install
Provide the appropriate ownership:
sudo chown -R www:www /usr/local/www/cachet
Open your site in a web browser and follow the instructions on the screen to finish the Cachet installation.
Step 7 - Complete the Cachet setup
Select cache and session drivers and configure mail options:
Configure general site settings like site name, site domain, timezone, and language:
Create an administrative user account:
After that, you should get a message that Cachet has been configured successfully. You can open the Cachet dashboard by pressing the "Go to dashboard" button:
Cachet installation and setup has been completed.
To access Cachet dashboard append /dashboard
to your website URL.