UbuntuUbuntu Based

How To Install Cacti on Ubuntu 24.04 LTS

Install Cacti on Ubuntu 24.04

In today’s interconnected world, network monitoring has become an essential aspect of maintaining a robust and efficient IT infrastructure. Cacti, an open-source network graphing and monitoring tool, has emerged as a popular choice among system administrators and network engineers. This comprehensive guide will walk you through the process of installing Cacti on Ubuntu 24.04 LTS, providing you with a powerful solution for visualizing and analyzing your network’s performance.

Cacti leverages the power of RRDtool (Round Robin Database) to store and display time-series data in visually appealing graphs. Its flexibility and extensibility make it an ideal choice for businesses of all sizes, from small startups to large enterprises. By choosing to install Cacti on Ubuntu 24.04 LTS, you’re opting for a stable, secure, and long-term supported operating system that perfectly complements Cacti’s robust features.

Prerequisites

Before we dive into the installation process, let’s ensure you have everything you need:

  • A server or virtual machine running Ubuntu 24.04 LTS
  • Root access or a user with sudo privileges
  • A minimum of 2GB RAM and 20GB of disk space
  • A stable internet connection

It’s crucial to have your system up-to-date and properly configured before proceeding with the Cacti installation. This ensures compatibility and reduces the likelihood of encountering issues during the setup process.

Updating the System

As with any software installation, it’s best to start with a freshly updated system. This step ensures that you have the latest security patches and package versions. Open your terminal and run the following commands:

sudo apt update
sudo apt upgrade -y

The first command updates the package lists, while the second upgrades all installed packages to their latest versions. The ‘-y’ flag automatically answers “yes” to any prompts, streamlining the upgrade process.

Installing LAMP Stack

Cacti requires a web server, a database, and PHP to function properly. The LAMP (Linux, Apache, MySQL, PHP) stack provides all these components. Let’s install each part of the stack:

Installing Apache

Apache is one of the most popular web servers. Install it using the following command:

sudo apt install apache2 -y

After installation, start and enable Apache to run on boot:

sudo systemctl start apache2
sudo systemctl enable apache2

Installing MySQL/MariaDB

For the database, we’ll use MariaDB, an open-source fork of MySQL. Install it with:

sudo apt install mariadb-server -y

Once installed, secure your MariaDB installation:

sudo mysql_secure_installation

Follow the prompts to set a root password and remove insecure default settings.

Installing PHP and Required Modules

Cacti requires PHP and several PHP modules. Install them with the following command:

sudo apt install php php-mysql php-snmp php-gd php-xml php-curl php-mbstring php-gmp php-intl php-json -y

After installation, restart Apache to load the new PHP modules:

sudo systemctl restart apache2

Configuring MySQL/MariaDB for Cacti

Now that we have our database server installed, let’s create a database and user for Cacti:

sudo mysql -u root -p

Enter your MariaDB root password when prompted. Then, run the following SQL commands:

CREATE DATABASE cacti;
CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace ‘your_password’ with a strong, unique password for the Cacti database user.

Installing Cacti

With our LAMP stack configured, we’re ready to install Cacti. First, add the Cacti repository to ensure we get the latest version:

sudo add-apt-repository ppa:cacti/cacti
sudo apt update

Now, install Cacti and its dependencies:

sudo apt install cacti cacti-spine -y

During the installation, you’ll be prompted to configure some aspects of Cacti:

  • Choose ‘apache2’ when asked which web server to configure.
  • Select ‘Yes’ to configure the database for Cacti with dbconfig-common.
  • Enter the database password you set earlier for the ‘cactiuser‘.

Configuring Apache for Cacti

Cacti’s installation process should have created an Apache configuration file. However, let’s ensure it’s properly set up:

sudo nano /etc/apache2/conf-available/cacti.conf

The file should contain something like this:

Alias /cacti /usr/share/cacti/site
<Directory /usr/share/cacti/site>
    Options +FollowSymLinks
    AllowOverride None
    <IfVersion >= 2.3>
        Require all granted
    </IfVersion>
    <IfVersion < 2.3>
        Order allow,deny
        Allow from all
    </IfVersion>
</Directory>

If everything looks correct, save and close the file. Then, enable the Cacti configuration and restart Apache:

sudo a2enconf cacti
sudo systemctl restart apache2

Setting Up Cacti Web Interface

With Cacti installed and Apache configured, it’s time to set up the web interface. Open your web browser and navigate to:

http://your_server_ip/cacti

You’ll be greeted by the Cacti installation wizard. Follow these steps:

  1. On the first page, click “New Install” and then “Next”.
  2. The next page will check your system for required components. If everything is green, click “Next”.
  3. Review the Cacti settings. The defaults should work fine in most cases. Click “Next”.
  4. On the Template Import page, select all available templates and click “Import”.
  5. Finally, you’ll reach the user setup page. The default username is “admin”. Set a strong password and click “Save”.

After completing the wizard, you’ll be redirected to the login page. Use the admin username and the password you just set to log in.

Install Cacti on Ubuntu 24.04

Configuring Cron Job for Cacti

Cacti relies on a cron job to periodically collect data and update graphs. The installation should have created a cron job, but let’s verify it:

sudo nano /etc/cron.d/cacti

You should see a line similar to this:

*/5 * * * * www-data php /usr/share/cacti/site/poller.php >/dev/null 2>&1

If the file doesn’t exist or the line is missing, add it manually. This cron job runs the Cacti poller every 5 minutes.

Basic Cacti Configuration

Now that Cacti is installed and running, let’s cover some basic configuration steps:

Adding Devices to Monitor

  1. In the Cacti web interface, go to “Console” > “Management” > “Devices”.
  2. Click “Add” to create a new device.
  3. Enter the device’s hostname or IP address, select the appropriate device template, and configure SNMP settings if needed.
  4. Click “Create” to add the device.

Creating Graphs

  1. After adding a device, go to “Console” > “Management” > “Graph Trees”.
  2. Create a new tree or select an existing one.
  3. Add your device to the tree.
  4. Go to “Console” > “Management” > “Graph Management”.
  5. Select your device and choose the graphs you want to create.

Customizing the Dashboard

Cacti’s dashboard is highly customizable. To add graphs to your dashboard:

  1. Go to “Console” > “Management” > “Graph Trees”.
  2. Select the graphs you want to display.
  3. Click “Add to Dashboard” at the bottom of the page.

Troubleshooting Common Issues

While installing and configuring Cacti, you might encounter some issues. Here are solutions to common problems:

Database Connection Errors

If Cacti can’t connect to the database, verify your database settings in /usr/share/cacti/site/include/config.php. Ensure the username, password, and database name are correct.

Permission Issues

Cacti needs write access to certain directories. If you’re seeing permission errors, run:

sudo chown -R www-data:www-data /usr/share/cacti/site/rra /usr/share/cacti/site/log

SNMP Configuration Problems

If you’re having trouble polling devices via SNMP, ensure SNMP is properly configured on both Cacti and the target devices. You can test SNMP connectivity using the snmpwalk command.

Security Considerations

To keep your Cacti installation secure:

  • Use HTTPS to encrypt traffic to the Cacti web interface.
  • Implement strong password policies for Cacti users.
  • Regularly update Cacti and all system packages.
  • Configure your firewall to restrict access to the Cacti web interface and SNMP ports.
  • Regularly backup your Cacti database and configuration files.

Congratulations! You have successfully installed Cacti. Thanks for using this tutorial for installing the Cacti on your Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Cacti website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button