How to Install Cacti on FreeBSD 13.0

Updated on June 9, 2022
How to Install Cacti on FreeBSD 13.0 header image

Cacti is an open-source network monitoring tool that monitors network traffic using the Simple Network Management Protocol (SNMP). It can monitor traffic on multiple network devices such as routers, switches, and servers and stores the data to create performance management graphs in a database. This article explains how to install Cacti on a FreeBSD 13.0 cloud server.


Before you begin, make sure you:

1. Install Required Packages

  1. Install the RRDTool and SNMP.

      $ sudo pkg install rrdtool net-snmp
  2. Install your preferred text editor.

      $ sudo pkg install nano
  3. Install required PHP extensions.

      $ sudo pkg install php74 php74-mysqli php74-mbstring php74-json php74-snmp php74-gd php74-gmp php74-ldap php74-zip php74-xml php74-ctype php74-openssl php74-simplexml php74-sockets php74-zlib php74-posix
  4. Edit the php.ini-production configuration file.

      $ sudo nano /usr/local/etc/php.ini-production
  5. Locate the [Date] section.

      ; Defines the default timezone used by the date functions
      ;date.timezone =
  6. Uncomment the date.timezone directive, and enter your timezone. For example Europe/London.

      date.timezone = Europe/London
  7. Locate the memory_limit directive, and change it from 128M to a value above 400MB.

      memory_limit = 500M
  8. Locate max_execution_time, and change it from 30 to 60 or more.

      max_execution_time = 60

    Save and close the file.

  9. Make a copy of the edited php.ini-production file and rename it to php.ini

      $ sudo cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
  10. Start PHP-FPM.

     $ sudo service php-fpm start
  11. Restart Apache.

     $ sudo apachectl restart

2. Setup the Database Server

  1. Import system timezones to the MySQL database.

      $ sudo mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
  2. Login to MySQL.

      $ sudo mysql -u root
  3. Create a new Cacti database.

      CREATE DATABASE cactidb DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
  4. Create the Cacti database user secured with a strong password.

      CREATE USER 'cacti_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; 
  5. Grant the user full privileges to the Cacti database.

      GRANT ALL on cactidb.* TO cacti_user@localhost;
  6. Grant the user read access to the MySQL TimeZone database.

      GRANT SELECT ON mysql.time_zone_name TO cacti_user@localhost;
  7. Refresh MySQL privileges.

  8. Exit the MySQL console.

  9. Edit the main MySQL configuration file.

      $ sudo nano /usr/local/etc/mysql/my.cnf
  10. Locate the following configurations at the bottom of the file.

     innodb_write_io_threads         = 8
     innodb_read_io_threads          = 8
  11. Change the directive values as below:

     innodb_write_io_threads         = 16
     innodb_read_io_threads          = 32

    Save and close the file.

  12. Restart the MySQL database server.

     $ sudo service mysql-server restart

3. Install Cacti

  1. Create the Cacti document root directory.

      $ sudo mkdir /usr/local/www/cacti
  2. Download the latest Cacti release file.

      $ wget
  3. Extract files.

      $ tar -xvf cacti-latest.tar.gz
  4. Move extracted files to the Cacti directory.

      $ sudo mv cacti-1.2.20/* /usr/local/www/cacti
  5. Import the Cacti database.

      $ sudo mysql -u root cactidb < /usr/local/www/cacti/cacti.sql
  6. Edit the Cacti configuration file.

      $ sudo nano /usr/local/www/cacti/include/config.php
  7. Find the following section.

      $database_type     = 'mysql';
      $database_default  = 'cacti';
      $database_hostname = 'localhost';
      $database_username = 'cactiuser';
      $database_password = 'cactiuser';
      $database_port     = '3306';
      $database_retries  = 5;
      $database_ssl      = false;
      $database_ssl_key  = '';
      $database_ssl_cert = '';
      $database_ssl_ca   = '';
      $database_persist  = false;
  8. Change the values to reflect your database server, user, and password.

      $database_type     = 'mysql';
      $database_default  = 'cactidb';
      $database_hostname = 'localhost';
      $database_username = 'cacti_user';
      $database_password = 'password';
      $database_port     = '3306';
      $database_retries  = 5;
      $database_ssl      = false;
      $database_ssl_key  = '';
      $database_ssl_cert = '';
      $database_ssl_ca   = '';
      $database_persist  = false;

    Save and close the file.

  9. Grant Apache read and write permissions on the directory.

      $ sudo chown -R www:www /usr/local/www/cacti

4. Configure Apache

  1. Create a new Apache Virtual Host configuration file.

      $ sudo touch /usr/local/etc/apache24/Includes/cacti.conf
  2. Edit the file.

      $ sudo nano /usr/local/etc/apache24/Includes/cacti.conf
  3. Add the following configurations to the file.

      <VirtualHost *:80>
      DocumentRoot "/usr/local/www/cacti"
      DirectoryIndex index.php index.html
      Alias /cacti /usr/local/www/cacti/
      <Directory /usr/local/www/cacti>
      AllowOverride None
      Order Allow,deny
      Allow from all
      Require all granted

    Save and close the file.

  4. Test the Apache Configuration.

      $ sudo apachectl configtest
  5. Restart Apache.

      $ sudo apachectl restart

5. Setup SSL

  1. Edit the main Apache configuration file.

      $ sudo nano /usr/local/etc/apache24/httpd.conf
  2. Locate the following module directives.

      #LoadModule ssl_module libexec/apache24/
      #LoadModule rewrite_module libexec/apache24/
  3. Uncomment them by removing #.

      LoadModule ssl_module libexec/apache24/
      LoadModule rewrite_module libexec/apache24/

    Save and close the file.

  4. Test the Apache configuration file.

      $ sudo apachectl configtest
  5. Install the Apache Certbot agent.

      $ sudo pkg install py38-certbot-apache py38-certbot
  6. Request a Let’s Encrypt SSL certificate.

      $ sudo certbot --apache -d

    Enter your email address and agree to Let's Encrypt terms.

  7. Restart Apache to load changes.

      $ sudo apachectl restart

6. Access Cacti

Open your web browser and load the Cacti web interface by visiting your configured subdomain or Server IP to complete the setup process.

To Login, use the following default username and password values.

  • USERNAME: admin
  • PASSWORD: admin

More Information

You have installed Cacti on FreeBSD 13.0. For more information, refer to the following articles.