How to Install Cachet on Debian 10
Cachet is an open-source status page system written in PHP. Cachet source code is hosted on Github. In this guide, we will go over the Cachet installation process on Debian 10 (buster) by using a PHP, MariaDB, and Nginx software stack.
Requirements
- PHP version 7.1.3 or greater
- HTTP server with PHP support (eg: Apache, Nginx, Caddy). This guide uses Nginx.
- A supported database: MySQL/MariaDB, PostgreSQL or SQLite. This guide uses MariaDB.
- Git
- Composer
Before you begin
Check the Debian version.
lsb_release -ds
# Debian GNU/Linux 10 (buster)
Create a new non-root
user account with sudo
access and switch to it.
adduser johndoe --gecos "John Doe"
usermod -aG sudo johndoe
su - johndoe
NOTE: Replace johndoe
with your username.
Set up the timezone.
sudo dpkg-reconfigure tzdata
Ensure that your system is up to date.
sudo apt update && sudo apt upgrade -y
Install needed packages.
sudo apt install -y zip unzip curl wget git
Install PHP
Install PHP, as well as the necessary PHP extensions.
sudo apt install -y php php-cli php-fpm php-common php-xml php-gd php-zip php-mbstring php-mysql php-pgsql php-sqlite3 php-apcu
Check the version.
php --version
# PHP 7.3.4-2 (cli) (built: Apr 13 2019 19:05:48) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.3.4-2, Copyright (c) 1999-2018, by Zend Technologies
Install MariaDB and create a database
Install MariaDB.
sudo apt install -y mariadb-server
Check the version.
mysql --version
# mysql Ver 15.1 Distrib 10.3.15-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Run the mysql_secure_installation
script to improve the security of your MariaDB installation.
sudo mysql_secure_installation
Log into MariaDB as the root user.
sudo mysql -u root -p
# Enter password:
Create a new MariaDB database and database user, and remember the credentials.
CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
quit
NOTE: Replace dbname
and username
with appropriate names for your setup. Replace password
with a strong password.
Install and configure Nginx
Install Nginx.
sudo apt install -y nginx
Check the version.
sudo nginx -v
# nginx version: nginx/1.14.2
Run sudo vim /etc/nginx/sites-available/cachet.conf
and configure Nginx for Cachet. Populate the file with the following configuration.
server {
listen 80;
listen [::]:80;
server_name status.example.com;
root /var/www/cachet/public;
index index.php;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_keep_conn on;
}
}
Save the file and exit with Colon + W + Q.
Activate the cachet.conf
configuration by linking the file to the sites-enabled
directory.
sudo ln -s /etc/nginx/sites-available/cachet.conf /etc/nginx/sites-enabled/
Test the configuration.
sudo nginx -t
Reload Nginx.
sudo systemctl reload nginx.service
Install Composer
Install Composer 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 the version.
composer --version
# Composer version 1.8.6 2019-06-11 15:03:05
Install Cachet
Create a document root directory.
sudo mkdir -p /var/www/cachet
Change ownership of the /var/www/cachet
directory to johndoe
.
sudo chown -R johndoe:johndoe /var/www/cachet
Navigate to document root.
cd /var/www/cachet
Download the Cachet source code with Git and checkout the latest tagged release.
git clone -b 2.4 --single-branch https://github.com/cachethq/Cachet.git .
Copy .env.example
to .env
and configure database and APP_URL
settings in .env
.
cp .env.example .env
vim .env
Install Cachet dependencies with Composer.
composer install --no-dev -o
Set up the application key.
php artisan key:generate
Install Cachet.
php artisan cachet:install
Change ownership of the /var/www/cachet
directory to www-data
.
sudo chown -R www-data:www-data /var/www/cachet
Open your site in a web browser and follow the instructions on the screen to finish the Cachet installation. To access the Cachet dashboard append /dashboard
to your website URL.