How to Install CachetHQ on Ubuntu 16.04

How to Install CachetHQ on Ubuntu 16.04

In this tutorial, we’ll show you how to install CachetHQ on Ubuntu 16.04, 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.

Requirements:

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

1. Login to your VPS via SSH

ssh user@vps

2. Update the system

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

3. 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.

4. Install Apache2 web server

[user]$ sudo apt-get install apache2

5. 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

6. 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/

7. 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

8. 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

9. 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>
    

10. Restart Apache and Verify the Installation

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 install CachetHQ on Ubuntu 16.04,  if you use one of our Blazing-Fast Ubuntu Servers, 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, on how to install CachetHQ on Ubuntu 16.04, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

2 thoughts on “How to Install CachetHQ on Ubuntu 16.04”

  1. 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.

    Reply

Leave a Comment