Installing Cacti on OpenBSD 7.1

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"

In this post you will learn how to install Cacti on OpenBSD 7.1


Cacti is an open-source, web-based frontend for the industry-standard logging tool RRDTool. It’s commonly used to monitor traffic via the Simple Network Management Protocol (SNMP).


We require the following packages in OpenBSD:

  • apache-httpd
  • rrdtool
  • net-snmp
  • mariadb-server
  • php

And some php modules:

  • php-cgi
  • php-apache
  • php-snmp
  • php-mysqli

Let’s install those using pkg_add(1).

Installing packages

Configuring PHP

Now we need to configure php so that it has all of the required modules loaded. The installation has installed a readme file at /usr/local/share/doc/pkg-readmes/php-8.0. We should have a look at it.

Now enable the modules at /etc/php-8.1.ini. Here, I’ve installed php version 8.1, so the filenames may not be exact.

Configure PHP

Configuring Apache

Now time for configuring the web server. The main configuration file for Apache is at /etc/apache2/httpd2.conf. This also loads the module configurations under /var/www/conf/modules/. The packages we installed automatically come with a php-8.1.conf file for configuraing our web server to use php. We just have to enable it.
Enable the php module with the following command.

ln -s /var/www/conf/modules.sample/php-8.1.conf /var/www/conf/modules/php.conf

Hopefully it’s self-explanatory.

We’ll also serve webpages from the /var/www/html/cacti/ directory so we have to edit the /etc/apache2/httpd2.conf file. Search for the htdocs keyword and modify so that it looks like the following.

Change DocumentRoot for Apache

Configure MariaDB

The package readme at /usr/local/share/doc/pkg-readmes/mariadb-server suggests us to install the default database first. Let’s do that.

Installing default database

Now let’s start the database server.

doas rcctl start mysqld

Let’s change the root password for the database.

Changing DB password

Then create a database for Cacti.

doas mysqladmin --user=root create cacti

Obtaining Cacti

We can download the latest version of Cacti from the downloads page.

Downloading Cacti

Now that’s been download, we can extract the tarball.

Extracting the tarball

Now we need to setup the cacti database that we just created. Fortunately, the package we downloaded comes with a default database schema.

Navigate to the extracted directory. and run the following command.

doas mysql cacti < cacti.sql

We should also create a separate user to handle this database.

Setup Cacti user credentials

Edit include/config.php and make sure the credentials are correct.

Edit include/config.php

Let’s also setup a unprivileged user for the cacti application. This can easily be done with the adduser(8) script.

Add the cactiuser

Now set the appropriate permissions on cacti’s directories. I’ve assumed you’re still in the extracted tarball directory.

doas chown -R cactiuser rra/ log/

Add a cron job for the poller:

doas crontab -e
Adding cron job

As we’ve specified the /var/www/html/ directory. Let’s move our download there.

Moving to proper directories

Now let’s run the web server and ensure our database is running.

Cacti on OpenBSD
Cacti on OpenBSD

Now the cacti instance should be accessible at http://localhost/cacti/. That’s it for today. Thank you for reading.


  1. The Cacti Manual
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"
Pratik Devkota
Pratik Devkota
Software engineering student interested in UNIX (GNU/Linux, *BSD, etc.), security as well as free and open-source software.


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook