How to Install CachetHQ on an Ubuntu 16.04 VPS


In this tutorial, we’ll show you how to install CachetHQ on an Ubuntu 16.04 VPS with MySQL and Apache2. CachetHQ makes it simple to create a status page for your application, service or network and it’s based on Laravel framework. This guide should work on other Linux VPS systems as well but was tested and written for Ubuntu 16.04 VPS.

At the time of writing this tutorial, Cachet v2.3.9 is the latest stable version available and it requires:

  • PHP 5.5.9+ or newer installed on your Linux VPS;
  • HTTP server with PHP support (eg: Apache, Nginx, Caddy)
  • Composer
  • A supported database: MySQL, PostgreSQL or SQLite

INSTRUCTIONS:

Login to your VPS via SSH

ssh [email protected]

Update the system

[user]$ sudo apt-get update && sudo apt-get -y upgrade

Install MariaDB 10.0

To install MariaDB, run the following command:

[user]$ sudo apt-get install -y mariadb-server

Next, we need to create a database for our Cachet installation.

[user]$ mysql -u root -p

MariaDB [(none)]> CREATE DATABASE cachet;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cachet.* TO 'cachetuser'@'localhost' IDENTIFIED BY 'your-password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Do not forget to replace ‘your-password’ with a strong password.

Install Apache2 web server

[user]$ sudo apt-get install apache2

Install PHP and required PHP modules

To install the latest stable version of PHP version 7 and all necessary modules, run:

[user]$ sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-mbstring php7.0-curl php7.0-zip php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-xml curl

Enable the Apache2 rewrite module if it is not already done:

[user]$ sudo a2enmod rewrite

In order to activate the new configuration, restart the Apache web server using the following command:

[user]$ sudo service apache2 restart

Download the source code with Git

[user]$ sudo cd /var/www/html/
[user]$ sudo git clone https://github.com/cachethq/Cachet.git
[user]$ sudo cd Cachet
[user]$ sudo git checkout v2.3.9

All files have to be readable by the web server, so we need to set a proper ownership

[user]$ sudo chown www-data:www-data -R /var/www/html/Cachet/

Configuring a database

Rename the .env.example file to .env using the following command:

[user]$ sudo mv .env.example .env

Open the .env file and change the following lines:

[user]$ sudo nano .env
APP_URL=http://localhost -> APP_URL=http://your-domain-name
DB_DATABASE=cachet -> DB_DATABASE=your-database-name
DB_USERNAME=homestead -> DB_USERNAME=your-database-username
DB_PASSWORD=secret -> DB_PASSWORD=your-database-password

Install Composer

Composer is a dependency manager for PHP with which you can install packages. Composer will pull in all the required libraries and dependencies you need for your project.

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

[user]$ sudo composer install --no-dev -o

Set the application key

Before going any further, we need to set the APP_KEY config. This is used for all encryption used in Cachet.

php artisan key:generate

Cachet comes with an installation command that will:

  • Run migrations
  • Run seeders (of which there are none)
php artisan app:install

Create a new virtual host directive in Apache. For example, create a new Apache configuration file named ‘cachet.conf’ on your virtual server:

[user]$ sudo touch /etc/apache2/sites-available/cachet.conf
[user]$ sudo ln -s /etc/apache2/sites-available/cachet.conf /etc/apache2/sites-enabled/cachet.conf
[user]$ sudo nano /etc/apache2/sites-available/cachet.conf

Then, add the following lines:

    <VirtualHost *:80>
    ServerName your-domain.com
    # Or whatever you want to use
    ServerAlias www.your-domain.com
    # Make this the same as ServerName
    DocumentRoot "/var/www/html/Cachet/public"
    <Directory "/var/www/html/Cachet/public">
        Require all granted 
        # Used by Apache 2.4
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
   </Directory>
   </VirtualHost>
    

Restart the Apache web server for the changes to take effect:

[user]$ sudo service apache2 restart

Open your favorite web browser, navigate to http://your-domain.com/ and if you properly configured everything the Cachet installer should be starting. You should follow the easy instructions on the install screen inserting the necessary information as requested.

That is it. The Cachet installation is now complete.

Of course, you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install Cachet for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Tutorials
How to install Vesta Control Panel on a Linux VPS
Tutorials
How to Install Python 3.6 on Ubuntu 16.04
Tutorials
How to Install Zikula on Ubuntu 16.04
  • Chris

    ChrisChris

    Author Reply

    Hi There,

    I have used your walk through and found it very easy to read / understand the one thing you’ve missed is a PHP Extension ext-xml

    Its a pre-req for composer install.


    • admin

      adminadmin

      Author Reply

      Thanks Chris, we updated the tutorial.


Leave a Reply to Chris
Cancel Reply