How To Install CachetHQ On a CentOS 7 VPS or Dedicated Server


Introduction

Cachet is a beautifully crafted, open-source status page system that helps system administrators communicate system outages and downtimes to shareholders, teams, and clients. It's a powerful application that provides a dashboard where users can easily measure instances such as error rates, uptime, or anything random. The solution is highly responsive and works seamlessly on any system.

This tutorial will show you how to install Cachet on your CentOS 7 server.

Ready? Let’s get started!

Before You Begin

For this tutorial to work flawlessly, you require the following:

Step 1 - Installing The LAMP Stack

Installing Apache

The first step, when installing Cachet on CentOS 7 is to install the LAMP stack. But first, run the command below to update your system’s package index:

$ sudo yum -y update

Next, install the Apache web server:

$ sudo yum install httpd

Once Apache is installed, run the command below to start the service and enable it to start at boot.

$ sudo systemctl start httpd.service
$ sudo systemctl enable httpd.service

Installing MariaDB

Now, it’s time to install the database server:

$ sudo yum install mariadb-server mariadb

When the MariaDB is installed, issue the command below to start it:

$ sudo systemctl start mariadb

Installing PHP 7.2

To get high performance, you need to install PHP 7.2 which is not provided in the YUM repository. For this reason, we need to install it from a third party repository:

First, run the command below to enable EPEL:

$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Then install the yum-utils.

$ sudo yum install yum-utils

Next, run the command below to enable Remi RPM repository:

$ sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

$ sudo yum-config-manager --enable remi-php72

You can now issue the command below to  install PHP 7.2:

$ sudo yum install php72 php72-php-fpm php72-php-mysqlnd php72-php-opcache php72-php-xml php72-php-xmlrpc php72-php-gd php72-php-mbstring php72-php-json

The command above will automatically install PHP 7.2 together with the required extensions. To confirm the PHP version installed, run the command below:

$ sudo php72 -v

This will give the following output:

php72 -v
PHP 7.2.10 (cli) (built: Sep 11 2018 10:09:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.10, Copyright (c) 1999-2018, by Zend Technologies

That is it! The LAMP stack is installed in your CentOS 7 server. You can now proceed with the other steps.

Step 2 - Installing Memcached

You need an application to cache your resources and Memcached in one of the best caching applications. To install Mecached, run the command below:

$ sudo yum -y install memcached

Next, execute the commands below to start Memcached and activate it to launch at boot:

$ sudo systemctl enable memcached
$ sudo systemctl start memcached

Step 3 - Setting The Time Zone

Cachet works seamlessly when your system time is in sync. For this reason, you must update your global time zone for the database server, to do so, run the command below to open database configuration file:

$ sudo nano /etc/my.cnf

Add the line below, immediately after the last line of this file:

default-time-zone='+05:30'

Note: Remember to change the time to match your timezone.

Step 4 - Create A Database For Cachet

Before you create a new database for Cache, run the command below to secure MariaDB:

$ sudo mysql_secure_installation

You will be prompted to enter your root password. Since you have just implemented MariaDB and no password has been set yet, press ENTER to continue. Create a strong password for the database and respond to all the other questions with Y.

Once everything is set, run the command below to log in to the MariaDB command line:

$ sudo mysql -u root -p

Type the password you created above, and hit ENTER to continue. When you access the MariaDB shell, issue the command below to fashion a new database called cachet_data.

MariaDB [(none)]>

CREATEDATABASE cachet_data;

Next, create a user called cachet_user

MariaDB [(none)]>

CREATEUSER'cachet_user'@'localhost'IDENTIFIEDBY'StrongPassword';

Lastly, run the command below to grant the user all privileges:

MariaDB [(none)]>

GRANT ALL PRIVILEGESON cachet_data.* TO'cachet_user'@'localhost';

Issue the command below to implement the changes:

MariaDB [(none)]>

FLUSHPRIVILEGES;

Step 5 - Installing Cachet

By now everything is set and it should be a breeze to install Cachet. But before you install Cachet, run the command below to install Composer; PHP’s dependency manager:

$ curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/bin/composer

Change to Apache’s webroot directory and download Cachet;

$cd /var/www git clone https://github.com/cachethq/Cachet.git cachet

Once the download is done, navigate to the new Cachet directory and check the releases:

$ cd cachet git tag-l

This will give you the following output:

v0.1.0-alpha
v1.0.0
v1.1.0
...
v2.3.10
v2.3.11

Run the command below to confirm the latest releases:

$ git checkout v2.3.11

Then copy the configuration for the example environment:

$ cp .env.example .env

Open the env file

$ sudo nano .env

Update the database settings to match those set when configuring the Cachet databases and assign the database port 3306:

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

Next, execute the command below to install the much-needed Composer dependencies:

$ sudo composer install --no-dev -o

Then generate an APP_KEY for encryption:

$ sudo php artisan key:generate

Once you generate the key, launch Cachet installer:

$ sudo php artisan app:install

Now, run the command below to generate a new virtualhost for web application:

$ sudo nano /etc/httpd/conf.d/status.yourdomain.com.conf

Once this file opens, add the content below:

<VirtualHost *:80>
    ServerAdmin me@liptanbiswas.com
    DocumentRoot"/var/www/cachet/public"
    ServerName status.yourdomain.com
    ServerAlias www.status.yourdomain.com
    <Directory "/var/www/cachet/public">
        Options Indexes FollowSymLinks
        AllowOverrideAll
        Order allow,deny
        Allow from all
        Requireall granted
    </Directory>
    ErrorLog"/var/log/httpd/status.yourdomain.com-error_log"
    CustomLog"/var/log/httpd/status.yourdomain.com-access_log" combined
</VirtualHost>

Note: Remember to amend the line status.yourdomain.com with your authentic domain.

Save the changes and exit the nano editor, then execute the command below to restart Apache:

$ sudo systemctl restart httpd

Next, modify the ownership:

$ sudo chown -R apache:apache /var/www/cachet/public

Now, run the command below to permit HTTP traffic via port 80:

$sudofirewall-cmd--zone=public--permanent--add-service=httpfirewall-cmd--reload

Finally, change the SELinux settings.

To disable SELinux temporarily without having to restart your CentOS 7 server, execute the command below:

$ sudo setenforce 0

Alternatively, to disable the utility permanently, open the SELinux configuration files

$ sudo nano /etc/selinux/config

Replace “enforcing” in the line SELINUX=enforcing, with “disabled” to get:

SELINUX=disabled

Conclusion

That is it! You have successfully installed Cachet on your CentOS 7 server. You can now search http://status.yourdomain.com using your favorite web browser to complete the post-installation process.

Check out these top 3 VPS services:

Was this article helpful?