How To Configure Cacti Nginx On Debian 9


How To Configure Cacti Nginx On Debian 9

Introduction

Cacti is a powerful open source monitoring and graphing solution that combines a powerful backend database, a web interface, and an easy-to-configure monitoring system to help you quickly start collecting data from your IT systems. Cacti can monitor and graph a wide range of system resources, including network bandwidth, disk space utilization, processor load, and more. Cacti also supports advanced alerting and monitoring features such as performance threshold thresholds, data logging, and custom-defined notification rules, for when you want more fine-grained control over your system. In this tutorial, we’ll show you how to install and configure Cacti on a Debian 9 server, with Nginx as the web server.

Prerequisites

In order to complete this tutorial, you’ll need: A Debian 9 server with a non-root user with sudo privileges and a basic firewall (like UFW). A properly configured Nginx web server with TLS encryption enabled. The latest version of Cacti.

Step 1 — Installing Required Dependencies

Before proceeding any further, make sure you update your packages and install some necessary dependencies. Update your package lists using the command:

sudo apt update

Install the required packages with the command:

sudo apt install mariadb-server php-mysql php-gd php-snmp snmp snmpd unzip

Once the installation is complete, start the Mariadb service and enable it to start automatically on boot with the following command:

sudo systemctl start mysql.service

sudo systemctl enable mysql.service

Step 2 — Securing MariaDB

Now that the MariaDB server is installed and running, it is recommended to secure it using the mysql_secure_installation script. This script helps you remove insecure default settings, set a secure MariaDB root password, and delete test databases and anonymous users. To run the script type the following command:

sudo mysql_secure_installation

You will be asked to provide a new password for the root user. Enter a secure password of your choice. Once the script finishes, the database server should be secured.

Step 3 — Creating a Cacti Database

Next, you will need to set up a database for Cacti. You can do this by logging into your MySQL/MariaDB server as root. To access it, type the following command:

sudo mysql -u root -p

When prompted, enter the MySQL root password that you created earlier.

Once you are logged in, create a database for Cacti with the following command:

CREATE DATABASE cacti;

This command will create a database named “cacti”.

Next, create a user and grant it privileges to access the database with the following command:

GRANT ALL ON cacti.* TO ‘cactiuser’@’localhost’ IDENTIFIED BY ‘secure_password’;

Make sure to replace secure_password with a strong password of your choice.

Next, flush the privileges with the following command:

FLUSH PRIVILEGES;

Once you are done, exit the console with the command:

EXIT;

Step 4 — Installing Cacti on Debian 9

Next, you will need to download the latest version of Cacti from its official website. At the time of writing this article, the latest version is 1.2.7. To download it, type the following command:

cd /tmpwget https://www.cacti.net/downloads/cacti-1.2.7.tgz

Once the download is complete, extract the downloaded archive to the document root directory of Nginx with the following command:

sudo tar -xzf cacti-1.2.7.tgz -C /var/www/html/

Next, rename the extracted folder to cacti with the following command:

sudo mv /var/www/html/cacti-1.2.7/ /var/www/html/cacti/

Step 5 — Configuring Nginx for Cacti

Next, you will need to configure Nginx to serve the Cacti files. To do that, create a new Nginx server block file with the following command:

sudo nano /etc/nginx/sites-available/cacti.conf

Add the following lines:

server {
listen 80;
server_name example.com;

root /var/www/html/cacti/;
index index.php;

location / {
try_files $uri $uri/ =404;
}

location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}

Make sure to replace example.com with your domain name. Save and close the file when you are finished.

Next, create a new symlink of the cacti.conf file to the sites-enabled directory with the following command:

sudo ln -s /etc/nginx/sites-available/cacti.conf /etc/nginx/sites-enabled/

Next, test the Nginx configuration and restart Nginx with the following commands:

sudo nginx -t
sudo systemctl restart nginx

Step 6 — Finishing the Installation

At this point, all the required components are installed and configured. To complete the installation, open your web browser and go to http://example.com/cacti/install. (Replace example.com with your domain name). You will be redirected to the Cacti installation wizard. On the first page, click on “Next” to proceed.

On the next page, you will be asked to select the language for the Cacti installation. Select your preferred language and click on “Next”.

On the following page, you will be asked to select the database type. Select “MySQL” and then click on “Next”.

Next, you will be asked to configure the database settings. Provide the database information that you have set up earlier. Enter the host name, database name, database user, and password. After providing the details, click on “Next”.

On the next page, click on “Next” to accept all the default settings. After that, the installation process will begin. Once the installation is complete, click on “Finish” to login to the Cacti dashboard.

Conclusion

In this tutorial, we have gone through the process of installing and configuring Cacti on a Debian 9 server. Now you can start monitoring your servers and services using Cacti. For more detailed information on Cacti, you can check out the official Cacti documentation on their website.

Thank you for reading this article. If you have any questions, please feel free to ask in the comments section below. Also, don’t forget to read our other articles for more information about web server management and security.

Leave a Reply

Your email address will not be published. Required fields are marked *