Installing Cacti on nixOS Latest

Cacti is a web-based network monitoring tool used to gather and analyze network statistics. In this tutorial, we will guide you through the installation process of Cacti on nixOS Latest.

Prerequisites

Before we proceed with the installation, there are a few prerequisites that need to be satisfied:

Step 1: Install required packages

The first step in installing Cacti is to install the required packages that enable it to function seamlessly. Use the following command to install the required packages:

sudo nix-env -i cacti mariadb rrdtool

Step 2: Configure the database

Cacti stores its data in a database, hence the need to set it up before the installation can proceed. We will use MariaDB as our database management system (DBMS) in this tutorial, to install it, execute the following command:

sudo nix-env -i mariadb

Next, configure MariaDB by creating the cacti database and a user, which will be used to access the database. Execute the following SQL statements:

sudo mysqladmin -u root password my_password # Replace my_password with your desired password.
sudo mysql_secure_installation
CREATE DATABASE cacti;
GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'cactipass';
FLUSH PRIVILEGES;

Step 3: Install and configure PHP

Cacti relies on PHP to run its web interface, so we need to install and configure it. Use the following command to install PHP:

sudo nix-env -i php php-fpm

Next, we will modify the PHP configuration file to include the appropriate settings. Execute the following command to open the file:

sudo nano /etc/php/php.ini

Locate the date.timezone variable, uncomment it, and set it to your preferred timezone. For example:

date.timezone = Asia/Kolkata

Save and close the file.

Step 4: Configure Apache web server

Cacti uses the Apache web server to run its web interface, so we need to install and configure it. Use the following command to install Apache:

sudo nix-env -i apacheHttpd

After installation, we need to create a virtual host for Cacti. Execute the following command to create a new file:

sudo nano /etc/httpd/conf/vhosts/cacti.conf

Add the following content to the file:

<VirtualHost *:80>
ServerName cacti.local
DocumentRoot "/var/www/cacti"
<Directory "/var/www/cacti">
  Options -Indexes +FollowSymLinks
  DirectoryIndex index.php
  AllowOverride All
  Require all granted
</Directory>
</VirtualHost>

Save and close the file.

Step 5: Configure Cacti

Next, we need to configure Cacti to use the database we created earlier. Use the following command to import the default configuration into the database:

sudo cacti_db_install -p my_password # Replace my_password with the password you set earlier for the root user.

Next, edit the Cacti configuration file for Apache by running the following command:

sudo nano /etc/cacti/apache.conf

Locate the following line:

Alias /cacti /usr/share/cacti/

And change it to:

Alias /cacti /var/www/cacti/

Save and close the file.

Step 6: Run Cacti

Finally, restart the Apache web server to apply the changes:

sudo systemctl restart apacheHttpd

Now open your web browser and navigate to http://cacti.local/cacti. You should now see the Cacti login page. Log in using the default credentials:

You can now start monitoring your network by adding hosts and configuring graphs in Cacti.

Conclusion

In this tutorial, we have shown you how to install Cacti on nixOS Latest. We hope you found it helpful and that it enables you to gather and analyze network statistics easily.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!