Cachet is an open-source status page system, written in PHP, that allows organizations to communicate downtime and system outages to their customers, teams, and stakeholders. It provides a simple and effective way to display the status of various services, report incidents, and schedule maintenance, increasing transparency and trust. This guide will detail the installation process in a Rocky Linux 9.5 environment.
Objectives
The main objective of this guide is to provide a comprehensive, step-by-step procedure for installing and configuring Cachet on a Rocky Linux 9.5 server. By the end of this tutorial, you will have:
A configured web server (Nginx) and PHP-FPM. A database server (MariaDB) ready for use. Cachet installed and functional. A basic status page ready to be customized.
Requirements
Before starting the installation process, ensure you have the following prerequisites:
Rocky Linux 9.5 Server Instance: You will need a virtual or dedicated server running Rocky Linux 9.5. For this guide, we assume you are using an instance provided by LetsCloud, but the steps can be adapted for other cloud providers or local hardware. Root or Sudo Access: You need administrative privileges (root access or a user with sudo permissions) to install packages, configure services, and modify system files. Basic Linux Command-Line Knowledge: Familiarity with navigating the shell, executing commands, and editing text files is expected (we will use nano in this guide, but feel free to use your preferred editor). (Optional, but Recommended) Domain Name: Although it is possible to access Cachet using the server's IP address, it is highly recommended to have a domain name (e.g., status.yoursite.com) pointed to your server's IP, especially for a production environment and for configuring HTTPS/SSL later.
Step 1: Update the System
Ensure your system is fully updated.
$$sudo dnf update -y
sudo dnf upgrade -y
Step 2: Install Additional Repositories (EPEL and Remi)
We need these repositories to get newer versions of PHP.
$$$$sudo dnf install -y epel-release
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
sudo dnf module reset php -y
sudo dnf module enable php:remi-8.1 -y # Cachet v3.x funciona bem com PHP 8.1
Step 3: Install PHP and Required Extensions
Install PHP and all the extensions Cachet requires.
$sudo dnf install -y php php-fpm php-cli php-json php-mysqlnd php-gd php-mbstring php-xml php-curl php-zip php-bcmath php-opcache php-pdo php-tokenizer php-common
Step 4: Install Nginx Web Server
Nginx will act as our web server.
$sudo dnf install -y nginx
Step 5: Install MariaDB Database
Cachet needs a database. We will use MariaDB.
$sudo dnf install -y mariadb-server
Step 6: Start, Enable, and Configure MariaDB
Start the MariaDB service, enable it to start on boot, and run the secure installation.
$$$sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation
Follow the on-screen prompts. It is recommended to:
- Set a root password (if not already set).
- Remove anonymous users.
- Disallow remote root login.
- Remove the test database.
- Reload privilege tables.
Step 7: Create Database and User for Cachet
Log in to MariaDB and create the database and user that Cachet will use.
$sudo mysql -u root -p
Enter the root password you set. Then, execute the following SQL commands, replacing `your_strong_password`` with a secure password:
mysql>mysql>mysql>mysql>mysql>CREATE DATABASE cachet DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'cachetuser'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON cachet.* TO 'cachetuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 8: Install Git and Composer
We need Git to clone Cachet and Composer to manage PHP dependencies.
$sudo dnf install -y git
Instalar Composer
$$$$php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
Step 9: Configure PHP-FPM
Edit the PHP-FPM configuration file to work with Nginx.
$sudo nano /etc/php-fpm.d/www.conf
Find the user and group lines and change their values to nginx:
user = nginx
group = nginx
Save the file (Ctrl+O) and exit (Ctrl+X). Then, start and enable PHP-FPM.
$$sudo systemctl start php-fpm
sudo systemctl enable php-fpm
Step 10: Download and Configure Cachet
Create the directory and clone Cachet:
$$$$sudo mkdir -p /var/www/cachet
sudo chown -R $USER:$USER /var/www/cachet
cd /var/www/cachet
git clone -b 3.x https://github.com/cachethq/cachet.git .
Adjust permissions:
$$$sudo chown -R nginx:nginx /var/www/cachet
sudo chmod -R 755 /var/www/cachet
sudo chmod -R 775 /var/www/cachet/storage /var/www/cachet/bootstrap/cache
Install dependencies with Composer:
$$cd /var/www/cachet
sudo -u nginx composer install --no-dev -o
Configure the .env environment file:
$$$sudo -u nginx cp .env.example .env
sudo -u nginx php artisan key:generate
sudo nano .env
Update the following sections in the .env file with your settings:
.env
APP_URL: Defina para o URL que você usará para acessar o Cachet (ex: http://seu_dominio_ou_ip). DB_CONNECTION: mysql. DB_HOST: 127.0.0.1. DB_PORT: 3306. DB_DATABASE: cachet. DB_USERNAME: cachetuser. DB_PASSWORD: your_strong_password.
Also configure the MAIL_* sections if you wish to send emails. Run the database migrations:
$sudo -u nginx php artisan migrate
Answer yes when prompted.
Create the first user:
$sudo -u nginx php artisan cachet:make:user
Follow the prompts to create your administrator user.
Step 11: Configure Nginx
Create a new Nginx configuration file for Cachet.
$sudo nano /etc/nginx/conf.d/cachet.conf
Paste the following configuration, replacing your_domain_or_ip with your domain or IP address.
cachet.conf
server {
listen 80;
server_name seu_dominio_ou_ip;
root /var/www/cachet/public;
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?<span class="math-inline">query\_string;
\}
location \= /favicon\.<18\>ico \{ access\_log off; log\_not\_found off; \}
location \= /robots\.txt</17\> \{ access\_log off; log\_not\_found off; \}
access\_log /var/log/nginx/cachet\.access\.log;
error\_log /var/log/nginx/cachet\.error\.log;
sendfile off;
location \~ \\\.php</span> {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm/www.sock; # Verifique se este caminho está correto
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
}
Check the Nginx configuration and restart the service.
$$$sudo nginx -t
sudo systemctl restart nginx
sudo systemctl enable nginx
Step 12: Configure the Firewall
Allow HTTP (and HTTPS if you plan to configure it) traffic through the firewall.
$$$sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Step 13: Configure SELinux
Rocky Linux uses SELinux, which can prevent Nginx and PHP from accessing files or the network. Execute these commands to allow the necessary access.
$$$$$sudo dnf install -y policycoreutils-python-utils
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/cachet/storage(/.)?"
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/cachet/bootstrap/cache(/.)?"
sudo restorecon -Rv /var/www/cachet
sudo setsebool -P httpd_can_network_connect_db on
Step 14: Configure Cron Job
Cachet needs a scheduled task to perform certain functions. Edit the crontab for the nginx user.
sudo crontab -e -u nginx
Add the following line at the end of the file:
* * * * * php /var/www/cachet/artisan schedule:run >> /dev/null 2>&1
Save and close the file.
Step 15: Access Cachet
Open your browser and navigate to http://your_ip
You should see the Cachet login page. Log in with the administrator user you created in Step 10.
Conclusion
Congratulations! If you followed all the steps in this guide, you have successfully installed and configured Cachet on your Rocky Linux 9.5 server. You now have a powerful open-source status page platform ready to be used.
With Nginx serving the site, PHP processing the application, and MariaDB storing the data, your Cachet system is ready to help you transparently communicate the status of your services, incidents, and scheduled maintenance to your users and team.
0 COMMENTS