How to Install Cachet on Linux

Updated on June 23, 2024
How to Install Cachet on Linux header image

Introduction

Cachet is an open source status page system which allows you to inform your users about outages, planned maintances and much more. In this guide we will be installing Cachet on Linux server already running Apache, PHP, and MySQL.

Requirements

  • Git
  • Apache2.4+
  • MySQL Server
  • CURL

Install Cachet

First, we have to clone Cachet itself from its Github repository in a directory which we'll be using for it later. Let's assume our directory is /opt/cachet/:

cd /opt/
git clone https://github.com/cachethq/Cachet.git cachet/
cd cachet/

Configuration

By default Cachet comes with an .env.example file. We'll need to rename this file to .env, regardless of the type environment you're working on. Once renamed, we can edit the file and configure Cache it:

APP_ENV=production
APP_DEBUG=false
APP_URL=http://localhost
APP_KEY=SomeRandomString

DB_DRIVER=mysql
DB_HOST=localhost
DB_DATABASE=cachet
DB_USERNAME=cachet
DB_PASSWORD=RANDOM_PASSWORD
DB_PORT=null

CACHE_DRIVER=apc
SESSION_DRIVER=apc
QUEUE_DRIVER=database
CACHET_EMOJI=false

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ADDRESS=null
MAIL_NAME="Demo Status Page"
MAIL_ENCRYPTION=tls

REDIS_HOST=null
REDIS_DATABASE=null
REDIS_PORT=null

GITHUB_TOKEN=null

Database

Cachet insists on a database in order to store data. In this guide, we'll be using a MySQL database. Create a new database using the following command:

mysql -u root -p
CREATE DATABASE cachet;

Note: using mysql -u root -p assumes you do not have a /root/.my.cnf with your MySQL server credentials.

We can now create a new MySQL user which is authorized to access our fresh database:

CREATE USER 'cachet'@'localhost' IDENTIFIED BY 'RANDOM_PASSWORD';
GRANT ALL PRIVILEGES ON cachet.* TO 'cachet'@'localhost';
FLUSH PRIVILEGES;

Composer

Cache it requires composer to function. Below is how we can install it:

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Application Key

Cachet provides a built-in method to generate an application key. Cachet uses this application key for all data which is being encrypted. That said, you would want to backup the key somewhere safe.

php artisan key:generate

Installation

Now you're ready to install Cachet using another simple command:

php artisan app:install 

Note: Never change your application key after this installation; otherwise, Cache will fail to decrypt the data, rendering your installation corrupted.

Apache2

Cachet itself is a web-based application. Therefore, we'll be using Apache to serve it, thus allowing access to it via browser.

Note: Cachet requires mod_rewrite to be enabled on your Apache server.

a2enmod rewrite

We can now continue with creating our VirtualHost. For this step, create a new file called cachet.conf in the /etc/apache2/sites-enabled/ folder:

<VirtualHost *:80>
    # Domain from where Cachet will be accessed
    ServerName cachet.dev 
    ServerAlias cachet.dev 
    DocumentRoot "/var/www/Cachet/public"
    <Directory "/var/www/Cachet/public">
        Require all granted 
        # Used by Apache 2.4
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Start

We can now start working with Cachet. Simply restart Apache2 using the following command:

service apache2 restart

Access

You should now be able to access your fresh Cachet installation on the domain you set before in the Apache2 config.

Conclusion

Cachet is a pretty well designed open source status page which works on nearly any UNIX and even on Windows based servers. As a result of that Cachet is open source, we can easily implement our own plugins if we're familiar with PHP. Happy Hacking!