How to install CachetHQ on Ubuntu 16.04 VPS

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

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

  • PHP 5.5.9+ or later installed on a Linux VPS;
  • HTTP server with PHP support (ex: Apache, Nginx, Caddy)
  • Composer
  • Supported databases: MySQL, PostgreSQL or SQLite

INSTRUCTIONS:

Login to your VPS via SSH

ssh [email protected]

Update the system

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

Install MariaDB 10.0

To install MariaDB, run the following command:

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

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

[destroyer]$ mysql -u root -p

MariaDB [(none)]> CREATE DATABASE cachet;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cachet.* TO 'cachetdestroyer'@'localhost' IDENTIFIED BY 'ваш-пароль';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> q

Remember to replace ‘your-password’ with a strong password.

Installing Apache2 web server

[destroyer]$ sudo apt-get install apache2

Install PHP and required PHP modules

To install the latest stable PHP version 7 and all required modules, run the following command:

[destroyer]$ 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 curl

Enable Apache2 rewrite module if not already done:

[destroyer]$ sudo a2enmod rewrite

To activate the new configuration, restart the Apache web server using the following command:

[destroyer]$ sudo service apache2 restart

Download the source code from Git

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

All files must be readable by the web server, so we need to set the correct property

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

Database setup

Rename the .env.example .env file with the following command:

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

Open the .env file and change the following lines:

[destroyer]$ sudo nano .env
APP_URL=http://localhost -> APP_URL=http://имя-домена
DB_DATABASE=cachet -> DB_DATABASE=ваше-имя-базы-данных
DB_destroyerNAME=homestead -> DB_destroyerNAME=ваше-destroyername-базы-данных
DB_PASSWORD=secret -> DB_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.

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

Install the app key

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

php artisan key:generate

Cachet comes with an install command that will:

  • Run migration
  • Running seeders (of which none are available)
php artisan app:install

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

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

Then add the following lines:

 <VirtualHost *:80>
    ServerName your-domain.ru
    # или что вы хотите использовать
    ServerAlias www.your-domain.ru
    # сделать это также как имя_сервера
    DocumentRoot "/var/www/html/Cachet/public"
    <Directory "/var/www/html/Cachet/public">
        Require all granted 
        # Используется в Apache 2.4
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
   </Directory>
   </VirtualHost>

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

[destroyer]$ sudo service apache2 restart

Open your favorite web browser, go to http://your-domain.ru/ and if you have configured all settings correctly Cachet must work. You have to follow the simple instructions on the installation screen by pasting in the required information as requested.

All. Cachet installation is complete.

Sidebar