Cachet is a free and open source status page system. It is written in PHP and supports all the major databases to store its data. It is beautiful, responsive and powerful status page system. Cachet is used to better communicate downtime and system outages to their customers, teams, and shareholders. It is translated into over 10 languages and uses simple but powerful JSON API. It provides scheduled maintenance management and displays different metrics.
In this tutorial, we will install Cachet on CentOS 7 server.
Cachet does not require any special hardware requirements. It can be installed on servers with a small amount of RAM. All the required dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run
sudo -i to switch to root user.
Before installing any package it is recommended that you update the packages and repository using the following command:
yum -y update
Once you have your system updated, you can proceed to install the LAMP stack. Start the LAMP installation by installing Apache web server and MariaDB, which is a fork of MySQL using the following command.
yum -y install httpd mod_rewrite mariadb-server mariadb git
Cachet can be installed on any version of PHP greater than 5.5.9. But as PHP 5.5.9 has reached the end of life. We will install PHP 7 to obtain high performance. PHP 7 is not included in default YUM repository, hence you will need to add the Webtatic repository in your system. Webtatic repository requires EPEL repository to work. Run the following command to install EPEL repository.
yum -y install epel-release
yum -y update
Now install Webtatic repository using the following commands.
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y update
To install PHP 7.1 and all the required PHP modules, run the following command.
yum -y install php71w php71w-openssl php71w-mysql php71w-cli php71w-mbstring php71w-dom php71w-gd php71w-simplexml php71w-mcrypt php71w-xml php71w-tokenizer
Once you have PHP installed, you can check the version of PHP using the following command.
You should get output similar to this.
[root@liptan-pc ~]# php -v PHP 7.1.4 (cli) (built: Apr 15 2017 08:07:03) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
Now start Apache web server and enable it to start at boot time using the following command.
systemctl start httpd
systemctl enable httpd
You will also need to install
Memcached for caching the resources. Install
Memcached using the following command.
yum -y install memcached
Now start and enable
Memcached to automatically start at boot time.
systemctl enable memcached
systemctl start memcached
Update the Global timezone for your MySQL server by editing the
/etc/my.cnf file. We will be using
nano in this tutorial to edit text files, if you do not have
nano you can install it using
yum -y install nano. Open the MySQL configuration file:
Now add the following line at the end of the file, change the timezone according to your area.
To start MariaDB and enable it to start at boot time using the following commands.
systemctl start mariadb
systemctl enable mariadb
Now run the following commands to secure your MySQL or MariaDB installation.
It will run a small script which asks you to provide the root password for MariaDB. As we have just installed MariaDB, the root password is not set, just press enter to proceed further. It will ask you if you want to set a root password for your MariaDB installation, choose
y and set a strong password for the installation. It will also ask you for removing test databases and anonymous users. Most of the questions are self-explanatory and you should answer
y to all the questions.
To create a database we will need to login to MySQL command line first. Run the following command for same.
mysql -u root -p
This will prompt you for the password, provide the root password of MySQL which you have set earlier. Now run the following query to create a new database for your Cachet installation.
CREATE DATABASE cachet_data;
The above query will create a database named
cachet_data. Make sure that you use semicolon at the end of each query as the query always ends with a semicolon. Once the database is created you can create a new user and grant all the permissions to the user for the database. Using root user is not recommended for the databases. To create a new database user, run the following query.
CREATE USER 'cachet_user'@'localhost' IDENTIFIED BY 'StrongPassword';
The above query will create a user with username
Cachet_user. You can use any preferred username instead of
StrongPassword with a strong password. Now provide the appropriate privileges to your database user over the database you have created. Run the following command.
GRANT ALL PRIVILEGES ON cachet_data.* TO 'cachet_user'@'localhost';
Now run the following command to immediately apply the changes on the database privileges.
Exit from MySQL prompt using
Now you will need to install Composer. Composer is a dependency manager for PHP.
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/bin/composer
Now switch to the webroot directory of Apache web server and download Cachet using following command.
git clone https://github.com/cachethq/Cachet.git cachet
Once the download finishes, go to the newly created Cachet directory and look for the releases of the software using the following command.
git tag -l
You will get output similar to this.
[root@ip-172-31-15-12 cachet]# git tag -l v0.1.0-alpha v1.0.0 v1.1.0 ... v2.3.10 v2.3.11
Now checkout the latest version of the application using the following command.
git checkout v2.3.11
Now copy the example environment configuration file using the following command.
cp .env.example .env
Open the environment file using your favorite text editor.
Now find the following lines:
DB_DATABASE=cachet DB_USERNAME=homestead DB_PASSWORD=secret DB_PORT=null
Update the lines with the database, database username, and password which you have created earlier. Assign the port
3306. It should look like shown below.
DB_DATABASE=cachet_data DB_USERNAME=cachet_user DB_PASSWORD=StrongPassword DB_PORT=3306
Now install the required Composer dependencies using the following commands.
composer install --no-dev -o
APP_KEY used for all the encryption in the application using the following command.
php artisan key:generate
Once the key is generated, run the Cachet installer using the following command.
php artisan app:install
Now you will need to create a virtual host for your web application. Run the following command for same.
Paste the following lines into the file.
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org DocumentRoot "/var/www/cachet/public" ServerName status.yourdomain.com ServerAlias www.status.yourdomain.com <Directory "/var/www/cachet/public"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all Require all granted </Directory> ErrorLog "/var/log/httpd/status.yourdomain.com-error_log" CustomLog "/var/log/httpd/status.yourdomain.com-access_log" combined </VirtualHost>
status.yourdomain.com with any domain or subdomain you want to use to access the application. Save the file and exit from the editor. Run the following command to restart your Apache server.
systemctl restart httpd
Now you will need to provide the ownership of the application to web server user using the following command.
chown -R apache:apache /var/www/cachet/public
You may also need to allow HTTP traffic on port
80 through the firewall if you are running one. Run the following commands ro do so:
firewall-cmd --zone=public --permanent --add-service=http
You will also need to disable SELinux. To temporarily disable SELinux without restarting the server, run the following command.
To completely disable the SELinux you will need to edit
Find the following line:
Change it to:
Now complete the installation using a web browser, go to the following link using your favorite web browser.
You will see the following page.
Choose the cache driver and session driver as
Memcached. Choose appropriate mail driver according to your requirement and provide the hostname, email address, username, and password. Click Next when done.
In next interface, you will need to provide basic information about your website.
Provide a site name and site domain. Select the appropriate time zone and language. Click Next once done. In next interface, you will need to create an administrator account.
Provide the username, email address and password for the admin account and click on Complete Setup. You will be taken to your Cachet dashboard.
In this tutorial, we have learned to install Cachet Status Page System on CentOS 7 server. You can now use the software to manage downtime and incidents.