×
Community Blog Create Your Own Status Page Using Cachet

Create Your Own Status Page Using Cachet

In this article, we will install Cachet Status Page System on an Alibaba Cloud ECS CentOS 7 server to manage page downtime and incidents.

By Sajid Qureshi, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud's incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Cachet is a free and open source status page system. It is written in PHP using Laravel framework and it is a self-hosted status page system. One of the greatest things about it is that it's easy to customize its theme to fit your branding. It helps you to better communicate downtime and system outages to their customers and teams. Some of its features are listed below:

  1. Beautifully crafted
  2. Translated into over 10 languages
  3. Powerful JSON API
  4. Two-factor authentication
  5. Scheduled maintenance
  6. Easy to use dashboard
  7. Markdown support for incident messages
  8. Subscriber notifications via email

Prerequisites

  1. You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get a free account in your Alibaba Cloud account. If you don't know about how to set up your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 1GB RAM and 1 Core processor.
  2. A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.
  3. Root user access

Update the System

It is recommended to upgrade the system and all available packages before installing any new packages. Execute the following command to upgrade the available packages.
yum -y update

Install LAMP Stack

Once you have your system updated, you will need to install LAMP. So let's install Apache web server, MariaDB and git using the following command.
yum -y install httpd mod_rewrite mariadb-server mariadb git

You already know that Cachet is written in PHP so you will need to install PHP. Here we will install PHP 7 but PHP 7 is not available in default YUM repository, so we will first install the EPEL repository using the following command.
yum -y install epel-release

Now install the Webtatic repository using the following command.
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Finally, install PHP 7 with required packages for Cachet.
yum -y install php71w php71w-openssl php71w-mysql php71w-cli php71w-mbstring php71w-dom php71w-gd php71w-simplexml php71w-mcrypt php71w-xml php71w-tokenizer

You can verify installation of PHP by checking the version PHP using the following command.
php -v

You should see something similar to this on your terminal.

[root@Sajid ~]# php -v
PHP 7.1.19 (cli) (built: Jul  1 2018 07:20:27) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

Next, start the Apache web server and enable it to automatically launch at boot time. You can do so using the following command.
systemctl start httpd && systemctl enable httpd

You will have to install Memcached, which is a distributed memory object caching system. You can use the following command to install Memcached.
yum -y install memcached

Next, start Memcached and enable it just like we have done for apache before.
systemctl enable memcached && systemctl start memcached

You'll need to edit a configuration file to update the timezone according to your area. You can edit the file using any text editor, here we are using nano text editor.
nano /etc/my.cnf

Add the following line at the end of the file, change the timezone according to your region.
default-time-zone='+05:30'

Save the file and exit from the text editor.

To start MariaDB and enable it to start at boot time using the following command.
systemctl start mariadb && systemctl enable mariadb

We recommend you to harden the security of the Cachet data and to do so run following command.
mysql_secure_installation

You'll be asked to provide a root password so enter an appropriate password and answer yes to all questions by pressing Y.

Set root password? [Y/n] Y  
 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

Now you'll have to create a database for Cachet so please follow the instructions.
mysql -u root -p

You'll be asked to enter the password so simply enter a password and now execute the following queries to create a new database.
CREATE DATABASE cachet_data;

The above query will create a database named cachet_data. For the database, you can use any name you prefer in the place of cachet_data. Make sure that you use semicolon at the end of each query as a query always ends with a semicolon. Once the database is created you can create a new user and grant the required permissions to the user for the database.
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 cachet_user. Replace StrongPassword with a strong password.

Now provide the appropriate privileges to your database user over the database you have created. Run the following query to do so.
GRANT ALL PRIVILEGES ON cachet_data.* TO 'cachet_user'@'localhost';

Now run the following query to immediately apply the changes on the database privileges.
FLUSH PRIVILEGES;

Now you can exit from MariaDB prompt using the following command.
exit

Installing Composer

The composer is a dependency for PHP and you'll have to install it first before installing Cachet. Simply run below commands and they'll do the job for you.
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/bin/composer

Install Cachet

You have installed the LAMP stack and all other required dependencies to install Cachet. Now switch to web root directory and download Cachet from git, using the following command.
cd /var/www
git clone https://github.com/cachethq/Cachet.git cachet

Now go to the cachet directory.
cd cachet

Next, look for the release of software and you can do so using the following command.
git tag -l

You should see something similar to this output.

[root@Sajid cachet]# git tag -l
v0.1.0-alpha
v1.0.0
v1.1.0
...
v2.3.8
v2.3.9

Let's check out the latest version of the cachet using the following command.
git checkout v2.3.9

Copy the example environment configuration file.
cp .env.example .env

Next, you'll need to edit the environment configuration file using any text editor.
nano .env

Find these below-given lines in the file.

DB_DATABASE=cachet
DB_USERNAME=homestead
DB_PASSWORD=secret
DB_PORT=null

Change the values of these lines according to your database for Cachet like this:

DB_DATABASE=cachet_data
DB_USERNAME=cachet_user
DB_PASSWORD=StrongPassword
DB_PORT=3306

Save the file and exit from the text editor.

Execute the following the command to install required composer dependencies.
composer install --no-dev -o

You'll need to generate and update a unique app key in environment configuration and you can do so using the following commands.
php artisan migrate

You will be asked for confirmation so type Yes and hit Enter button.
php artisan key:generate

You should see your output similar to this:

Generating optimized class loader
Compiling common classes
> php artisan config:cache
Configuration cache cleared!
Configuration cached successfully!
> php artisan route:cache
Route cache cleared!
Routes cached successfully!

Next, Run the Cachet installer. Execute the following command and it will do the job for you.
php artisan app:install

Create Virtual Host

You will need to create a virtual host for your application to access it through the web. To create a virtual host use the following command.
nano /etc/httpd/conf.d/vhost.conf

Add the following content to the file and exit from the editor.

<VirtualHost *:80>
    ServerAdmin admin
    DocumentRoot "/var/www/cachet/public"
    ServerName YourDomain
    ServerAlias www.YourDomain
    <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>

Replace YourDomain with the actual domain name that you want to use for Cachet and change the value of ServerAdmin according to you.

Restart your Apache web server to apply the changes that we just configured.
systemctl restart httpd

Next, change the ownership permissions using the following command.
chown -R apache:apache /var/www/cachet/public

You'll need to modify firewall rules to allow HTTP traffic on port 80. Simply execute the following commands one by one and they will do the job for you.
firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --reload

Next, temporarily disable SELinux services using the following command.
setenforce 0

Finally, execute the following commands one by one to finish this installation.
chmod -R gu+w storage
chmod -R guo+w storage

Web Interface

Open up your favorite web browser and visit http://YourDomainName/ and you'll see the following web page on the screen.

1

Choose Memcached as cache driver and session driver. Choose mail driver and other details according to your requirement and then click on Next button.

You will see the next interface like this:

2

Provide your basic information about your website and select a time zone according to your region. Click on Next button when done.

You will see the next interface like this:

3

You'll be asked to enter administrative account details like username, email address and password for the admin so simply enter all the details and then finally click on Complete Setup button.

You will be informed that Cachet has been configured successfully. You can now click on the Go the dashboard button to log in with your admin credentials and visit Cachet's dashboard page.

4

You can add service components API, websites, incidents, matrices and much more from the Cachet dashboard. You can also schedule maintenance of your application from there.

You can set up mechanism to update new incidents or update metric data for this status page.

Conclusion

In this tutorial, you have learned to install Cachet Status Page System on an Alibaba Cloud Elastic Compute Service (ECS) CentOS 7 server. You can now use the software to manage downtime and incidents. We hope now you have enough knowledge to work with Cachet.

0 0 0
Share on

Sajid Qureshi

5 posts | 0 followers

You may also like

Comments

Sajid Qureshi

5 posts | 0 followers

Related Products