How to Install Cachet on Linux


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=productionAPP_DEBUG=falseAPP_URL=http://localhostAPP_KEY=SomeRandomStringDB_DRIVER=mysqlDB_HOST=localhostDB_DATABASE=cachetDB_USERNAME=cachetDB_PASSWORD=RANDOM_PASSWORDDB_PORT=nullCACHE_DRIVER=apcSESSION_DRIVER=apcQUEUE_DRIVER=databaseCACHET_EMOJI=falseMAIL_DRIVER=smtpMAIL_HOST=mailtrap.ioMAIL_PORT=2525MAIL_USERNAME=nullMAIL_PASSWORD=nullMAIL_ADDRESS=nullMAIL_NAME="Demo Status Page"MAIL_ENCRYPTION=tlsREDIS_HOST=nullREDIS_DATABASE=nullREDIS_PORT=nullGITHUB_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 -pCREATE 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!

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article

No comments

Powered by Blogger.