docs: fix SELinux policy guidance and add CentOS EOL notices to LAMP/LEMP guides (#209)

* docs: fix SELinux policy guidance and add CentOS EOL notices

Refs #209

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* docs: scope the AppArmor section to actually-confined Apache

Ubuntu and Debian enable AppArmor but ship no Apache profile by default, so
Apache runs unconfined and the reload commands error out on a stock system.
Gate the section on an Apache profile being present before applying overrides.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Co-authored-by: netniV <netniv@hotmail.com>
This commit is contained in:
Thomas VincentandnetniV authored and GitHub committed 2026-08-16 20:36:45 +01:00
1 parent cb29d10426
commit 9c0d7babc3
4 files changed
+1198 -2

No files matched your search

+571
View File
@@ -0,0 +1,571 @@
# Installing on CentOS/RHEL/Rocky Linux/AlmaLinux
> **Note:** CentOS Linux reached end-of-life on June 30, 2024 (CentOS 7) and December 31, 2021 (CentOS 8). New installations should use [Rocky Linux](https://rockylinux.org/) or [AlmaLinux](https://almalinux.org/), which are binary-compatible RHEL rebuilds. The commands in this guide apply to both.
> **Note**: As of Cacti 1.2.31, PHP 8.1 is required and PHP Composer is required.
> Composer will be used to ensure all of the libraries are installed and are up to date.
## LAMP (Linux, Apache, MySQL/MariaDB, PHP) Required packages
### Web Server (Apache)
1. For RHEL/Rocky Linux/AlmaLinux 8+
```console
dnf module reset php
dnf module enable php:8.1
```
### A special Note on installing Cacti in LXC Containers such as the ones found on Proxmox
It is recommended to create a privileged container you may need to update your containers config file with
```console
lxc.apparmor.profile: unconfined
```
This will allow for ICMP ping and other functions to work
A tested configuration file like below should be good however tune to your needs/standards
```console
arch: amd64
cores: 2
hostname: cacti
memory: 2048
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=mac-id,ip=dhcp,type=v>
ostype: ubuntu
rootfs: local-lvm:vm-110-disk-0,size=8G
swap: 2048
lxc.apparmor.profile: unconfined
```
### A special note for systems using PHP-FPM
Prior to starting the setup process of Cacti you should restart the PHP-FPM
Daemon to rebuild the Cache or you may receive a HTTP 500 Error
```console
systemctl restart php-fpm
```
2. Install Apache
```console
dnf install -y httpd
```
3. Enable and start the service to ensure it starts when the system reboots
```console
systemctl start httpd
systemctl enable httpd
```
### Example configuration file for Apache 2.4 and SSL
This example configuration assumes you have your own certificates already. You
should make sure you change the paths to match your setup.
Replace `YourOwnCertFile.crt` and `YourOwnCertFile.key` with the names of the
files holding your certificate (`.crt`) and private key (`.key`).
```console
#
# Cacti: An RRDtool based graphing web application
#
# For security reasons, the Cacti web interface is accessible only to
# localhost in the default configuration. If you want to allow other clients
# to access your Cacti installation, change the httpd ACLs below.
# For example:
# On httpd 2.4, change "Require host localhost" to "Require all granted".
# On httpd 2.2, change "Allow from localhost" to "Allow from all".
<VirtualHost *:443>
LogLevel warn
ServerName cacti.yourdomain.com
ServerAdmin admin@yourdomain.com
DocumentRoot "/var/www/html/cacti"
Alias /cacti /var/www/html/cacti
SSLEngine On
SSLCertificateFile /etc/ssl/certs/YourOwnCertFile.crt
SSLCertificateKeyFile /etc/ssl/private/YourOwnCertKey.key
<Directory /var/www/html/cacti/>
<IfModule mod_authz_core.c>
# httpd 2.4
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
# httpd 2.2
Order deny,allow
Deny from all
Allow from all
</IfModule>
</Directory>
<Directory /var/www/html/cacti/install>
# mod_security overrides.
# Uncomment these if you use mod_security.
# allow POST of application/x-www-form-urlencoded during install
#SecRuleRemoveById 960010
# permit the specification of the RRDtool paths during install
#SecRuleRemoveById 900011
</Directory>
# These sections marked "Require all denied" (or "Deny from all")
# should not be modified.
# These are in place in order to harden Cacti.
<Directory /var/www/html/cacti/log>
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Directory>
<Directory /var/www/html/cacti/rra>
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Directory>
</VirtualHost>
```
### Database Server
The choice between MySQL server and MariaDB is normally down to the OS
maintainers if you use one of the predefined LAMP setup installations. If you
are deciding between these yourself, you should research this via your
favorite search engine.
Whilst MySQL is the original open source SQL database server created in 1995
which is now owned by Oracle, MariaDB is designed as a drop-in replacement by
some of the original MySQL developers / owners. This will likely continue to
be a drop-in alternative until there is a major divergence that can not be
bridged.
#### MySQL
1. Install MySQL server
```console
dnf install -y mysql mysql-server
```
2. Enable and start the service to ensure it starts when the system reboots
```console
systemctl enable mysqld
systemctl start mysqld
```
#### MariaDB
1. Install MariaDB server
```console
dnf install -y MariaDB-server MariaDB-client
```
2. Enable and start the service to ensure it starts when the system reboots
```console
systemctl enable mariadb
systemctl start mariadb
```
### MySQL/MariaDB common tasks and recommendations
**IMPORTANT**: Secure your MySQL installation before doing any more changes
```console
/usr/bin/mysql_secure_installation
```
The following MySQL/MariaDB recommendations may vary depending on your system
setup. In any case, Cacti will prompt you with more accurate recommendations
during the installation.
1. Edit your `server.cnf` file
```console
vim /etc/my.cnf.d/server.cnf
```
The following `[mysqld]` section is a base configuration. The installer
will provide recommendations based on the actual system which will be more
tailored to your environment.
If using MariaDB less than version 11.1 or MySQL use the settings below.
Note that you should revise up or down your settings depending on
the Cacti recommendation that you see once you start the installer.
```shell
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
max_allowed_packet = 16777777
join_buffer_size = 32M
innodb_file_per_table = ON
innodb_buffer_pool_size = 250M
innodb_flush_log_at_trx_commit = 2
log-error = /var/log/mysql/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log = 1
slow-query-log-file = /var/log/mysql/mysql-slow.log
```
If using MariaDB 11.0 or higher, use the settings below:
```shell
[mariadb]
max_heap_table_size=500M
character_set_client=utf8mb4
character_set_server=utf8mb4
collation_server=utf8mb4_unicode_ci
innodb_buffer_pool_size=8G
innodb_doublewrite=OFF
tmp_table_size=500M
log-error = /var/log/mysql/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log = 1
slow-query-log-file = /var/log/mysql/mysql-slow.log
```
3. Restart MySQL/MariaDB service to pick up the changes
```console
systemctl restart mysql
```
4. Populate timezone table with available timezones
```console
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
```
#### Setup Cacti database
1. Login to MySQL/MariaDB as root to create Cacti database
```console
# mysql -u root -p
MariaDB [(none)]> create database if not exists cacti;
Query OK, 1 row affected (0.00 sec)
```
2. Import Cacti database from SQL file
```sql
MariaDB [(none)]> use cacti;
Database changed
MariaDB [(cacti)]> source /var/www/html/cacti/cacti.sql
```
3. Grant Cacti username access to Cacti database. Replace `your_cacti_username`
and `your_cacti_password` with your own details.
```sql
MariaDB [(none)]> CREATE USER 'your_cacti_username'@'localhost'
IDENTIFIED BY 'your_cacti_password';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cacti.* TO 'your_cacti_username'@'localhost';
Query OK, 0 rows affected (0.00 sec)
```
4. Grant cacti username to MySQL timezone table
```sql
MariaDB [(none)]> GRANT SELECT ON mysql.time_zone_name TO 'your_cacti_username'@'localhost';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
```
5. Save the Database Charset and Collation
```sql
MariaDB [(none)]> ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
MariaDB [(none)]> FLUSH PRIVILEGES;
```
### Common packages
#### PHP
PHP and various packages are all required by Cacti for successful operation
1. Install PHP and required packages.
```console
dnf install -y php php-common php-bcmath php-cli \
php-mysqlnd php-gd php-gmp php-intl \
php-json php-ldap php-mbstring \
php-pdo php-pear php-snmp php-process \
php-xml php-zip composer
```
2. Set a timezone to your PHP.INI configuration
Edit php.ini typically located at `/etc/php.ini`
```console
date.timezone = Pacific/Auckland
```
#### RRDtool
RRDtool is required to store the data retrieved from devices in `.rra` files to
produce the graphs which are shown within Cacti
```console
dnf install -y rrdtool
```
#### SNMP
SNMP is used to query most devices for information.
```console
dnf install -y net-snmp net-snmp-utils
```
### Cacti
The following steps will show you how to manually download, install and
configure the basics for Cacti.
1. Download Cacti source code from [Cacti Web
Site](https://www.cacti.net/download_cacti.php)
```console
cd /tmp
wget https://www.cacti.net/downloads/cacti-1.y.z.tar.gz
tar -zxvf cacti-1.y.z.tar.gz
mv -v cacti-1.y.z /var/www/html/cacti
```
2. Edit the config.php file
```console
mv -v /var/www/html/cacti/include/config.php-dist /var/www/html/cacti/include/config.php
```
3. Update `database_` fields with your own details. This section only applies
to the Main Cacti Server
```php
$database_type = 'mysql';
$database_default = 'your_cacti_database';
$database_hostname = 'localhost';
$database_username = 'your_cacti_username';
$database_password = 'your_cacti_password';
$database_port = '3306';
$database_ssl = false;
$database_ssl_key = '';
$database_ssl_cert = '';
$database_ssl_ca = '';
```
4. Create your cron task file or systemd units file
Starting with Cacti 1.2.16, you have the option to use either the
legacy Crontab entry, or an optional cactid units file and server
to run your Cacti pollers.
For Crontab use, follow the instructions below:
Create and edit `/etc/cron.d/cacti` file.
Make sure to setup the correct path to poller.php
```console
*/5 * * * * apache php /var/www/html/cacti/poller.php &>/dev/null
```
For systemd unit's file install, you will need to modify the
included units file to following your install location
and desired user and group's to run the Cacti poller as.
To complete the task, follow the procedure below:
```console
vim /var/www/html/cacti/service/cactid.service (edit the path)
touch /etc/sysconfig/cactid
cp -p /var/www/html/cacti/service/cactid.service /etc/systemd/system
systemctl enable cactid
systemctl start cactid
systemctl status cactid
```
The systemd units file makes managing a highly available Cacti
setup a bit more convenient.
#### Spine
1. Install the necessary packages to compile and install spine
On RHEL 8 / Rocky Linux 8 / AlmaLinux 8, enable the PowerTools repository first:
```console
dnf config-manager --set-enabled powertools
```
On RHEL 9 / Rocky Linux 9 / AlmaLinux 9, the equivalent repository is called `crb`:
```console
dnf config-manager --set-enabled crb
```
Then install the build dependencies:
```console
dnf install -y autoconf automake libtool dos2unix help2man \
openssl-devel mariadb-devel net-snmp-devel
```
2. Download spine source code from [Cacti Web
Site](https://www.cacti.net/spine_download.php)
Go to /tmp to download the source code and extract it
```console
cd /tmp
wget https://www.cacti.net/downloads/spine/cacti-spine-1.y.z.tar.gz
tar -zxvf cacti-spine-1.y.z.tar.gz
cd cacti-spine-1.y.z
```
3. Run the configure script and compile spine.
```console
# ./configure
# make & make install
config/install-sh -c -d '/usr/local/spine/bin'
/bin/sh ./libtool --mode=install /usr/bin/install -c spine '/usr/local/spine/bin'
libtool: install: /usr/bin/install -c spine /usr/local/spine/bin/spine
config/install-sh -c -d '/usr/local/spine/etc'
/usr/bin/install -c -m 644 spine.conf.dist '/usr/local/spine/etc'
config/install-sh -c -d '/usr/local/spine/share/man/man1'
/usr/bin/install -c -m 644 spine.1 '/usr/local/spine/share/man/man1'
```
4. Edit spine.conf
Rename spine.conf.dist to spine.conf
```console
mv -v /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
vi /usr/local/spine/etc/spine.conf
```
5. Now set up your database connection
```console
DB_Host localhost
DB_Database your_cacti_database
DB_User your_cacti_username
DB_Pass your_cacti_password
DB_Port 3306
#DB_UseSSL 0
#RDB_SSL_Key
#RDB_SSL_Cert
#RDB_SSL_CA
```
### Security Enhanced Linux (SELinux)
If you suspect SELinux is blocking Cacti, disable it temporarily to confirm, then re-enable it and apply the correct policy rather than leaving it disabled.
The [RHEL SELinux documentation](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/using_selinux/) covers policy management in depth and applies equally to Rocky Linux and AlmaLinux.
1. Check SELinux status
```console
getenforce
```
2. Disable SELinux temporarily for testing
```console
setenforce 0
```
3. Re-enable SELinux
```console
setenforce 1
```
4. Configure SELinux booleans for Cacti
Cacti requires two booleans so Apache can reach the database and make outbound SNMP connections during polling:
```console
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_can_network_connect_db 1
```
5. Set file contexts (only needed if Cacti is outside `/var/www/html`)
If you installed Cacti to a non-default path, apply the correct SELinux file contexts. The `semanage` command is provided by `policycoreutils-python-utils`; install it first if not already present:
```console
dnf install -y policycoreutils-python-utils
```
Replace `/path/to/cacti` with your actual install path:
```console
semanage fcontext -a -t httpd_sys_content_t "/path/to/cacti(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t "/path/to/cacti/rra(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t "/path/to/cacti/log(/.*)?"
restorecon -Rv /path/to/cacti
```
These labels grant Apache read access to Cacti's files and write access to the RRD and log directories. Without `httpd_sys_rw_content_t` on `rra/` and `log/`, graph generation silently fails even when UNIX permissions appear correct.
### Considerations when using Proxies in front of Cacti (Cacti 1.2.23+)
For optimal security, only specify the HTTP headers that are set by your proxy
software to prevent unauthorized access.
These can be set by editing the following section of config.php
```ini
* Allow the use of Proxy IPs when searching for client
* IP to be used
*
* This can be set to one of the following:
* - false: to use only REMOTE_ADDR
* - true: to use all allowed headers (not advised)
* - array of one or more the following:
*'X-Forwarded-For',
*'X-Client-IP',
*'X-Real-IP',
*'X-ProxyUser-Ip',
*'CF-Connecting-IP',
*'True-Client-IP',
*'HTTP_X_FORWARDED',
*'HTTP_X_FORWARDED_FOR',
*'HTTP_X_CLUSTER_CLIENT_IP',
*'HTTP_FORWARDED_FOR',
*'HTTP_FORWARDED',
*'HTTP_CLIENT_IP',
*
* NOTE: The following will always be checked:
*'REMOTE_ADDR',
*/
$proxy_headers = null;
```
**Note:** If you installed Cacti outside `/var/www/html`, run the `semanage fcontext` and `restorecon` commands from step 5 of the SELinux section above to apply the correct file contexts.
---
Copyright (c) 2004-2026 The Cacti Group
+581
View File
@@ -0,0 +1,581 @@
# Installing on CentOS/RHEL/Rocky Linux/AlmaLinux (LEMP)
> **Note:** CentOS Linux reached end-of-life on June 30, 2024 (CentOS 7) and December 31, 2021 (CentOS 8). New installations should use [Rocky Linux](https://rockylinux.org/) or [AlmaLinux](https://almalinux.org/), which are binary-compatible RHEL rebuilds. The commands in this guide apply to both.
> **Note**: As of Cacti 1.2.31, PHP 8.1 is required and PHP Composer is required.
> Composer will be used to ensure all of the libraries are installed and are up to date.
## LEMP (Linux, Nginx, MySQL, PHP) Required packages
### Web Server
1. Install Nginx
```console
dnf install -y nginx
```
2. Enable and start the service to ensure it starts when the system reboots
```console
systemctl start nginx
systemctl enable nginx
```
### Example configuration file for Nginx and SSL
This example assumes you have your own certificates already. You should make
sure you change the paths to match your setup.
Replace `YourOwnCertFile.crt` and `YourOwnCertFile.key` with the names of the
files holding your certificate (`.crt`) and private key (`.key`).
```console
/etc/nginx/conf.d/cacti.conf
```
```console
# Advanced config for NGINX
#server_tokens off;
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options nosniff;
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
server_name cacti.yourdomain.com;
return 301 https://$host$request_uri;
}
# SSL configuration
server {
listen 443 ssl default deferred;
server_name cacti.yourdomain.com;
root /usr/share/nginx/html/cacti;
index index.php index.html index.htm;
# Compression increases performance0
gzip on;
gzip_types text/plain text/html text/xml text/css application/xml application/javascript application/x-javascript application/rss+xml application/xhtml+xml;
gzip_proxied no-cache no-store private expired auth;
gzip_min_length 1000;
location / {
try_files $uri $uri/ /index.php$query_string;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html/;
}
location ~ \.php$ {
alias /usr/share/nginx/html/cacti;
index index.php
try_files $uri $uri/ =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# you may have to change the path here for your OS
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location /cacti {
root /usr/share/nginx/html/;
index index.php index.html index.htm;
location ~ ^/cacti/(.+\.php)$ {
try_files $uri =404;
root /usr/share/nginx/html;
# you may have to change the path here for your OS
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/cacti/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
expires max;
log_not_found off;
}
}
location /doc/ {
alias /usr/share/nginx/html/cacti/doc/;
location ~* ^/docs/(.+\.(html|md|txt))$ {
root /usr/share/nginx/html/cacti/;
autoindex on;
allow 127.0.0.1; # Change this to allow your local networks
allow ::1;
deny all;
}
}
location /cacti/rra/ {
deny all;
}
## Access and error logs.
access_log /var/log/nginx/cacti_access.log;
error_log /var/log/nginx/cacti_error.log info;
ssl_certificate /etc/ssl/certs/YourOwnCertFile.crt;
ssl_certificate_key /etc/ssl/private/YourOwnCertKey.key;
# Improve HTTPS performance with session resumption
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
# Prefer server cipher order; use only TLS 1.2+ (TLS 1.0/1.1 prohibited by RFC 8996)
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:!ADH:!AECDH:!MD5;
ssl_protocols TLSv1.2 TLSv1.3;
# Diffie-Hellman parameter for DHE cipher suites
# $ sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 4096
ssl_dhparam /etc/ssl/certs/dhparam.pem;
# Enable HSTS (https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security)
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
}
```
### Database Server
The choice between MySQL server and MariaDB is normally down to the OS
maintainers if you use one of the predefined LAMP setup installations. If you
are deciding between these yourself, you should research this via your favorite
search engine.
Whilst MySQL is the original open source SQL database server created in 1995
which is now owned by Oracle, MariaDB is designed as a drop-in replacement by
some of the original MySQL developers / owners. This will likely continue to be
a drop-in alternative until there is a major divergence that can not be bridged.
#### MySQL
1. Install MySQL server
```console
dnf install -y mysql mysql-server
```
2. Enable and start the service to ensure it starts when the system reboots
```console
systemctl enable mysqld
systemctl start mysqld
```
#### MariaDB
1. Install MariaDB server
```console
dnf install -y MariaDB-server MariaDB-client
```
2. Enable and start the service to ensure it starts when the system reboots
```console
systemctl enable mariadb
systemctl start mariadb
```
### MySQL/MariaDB common tasks and recommendations
**IMPORTANT**: Secure your MySQL installation before doing any more changes
```console
/usr/bin/mysql_secure_installation
```
The following MySQL/MariaDB recommendations may vary depending on your system
setup. In any case, Cacti will prompt you with more accurate recommendations
during the installation.
1. Edit your **server.cnf** file
```console
vim /etc/my.cnf.d/server.cnf
```
The following `[mysqld]` section is a base configuration. The installer will
provide recommendations based on the actual system which will be more
tailored to your environment.
If using MariaDB less than version 11.1 or MySQL use the settings below.
Note that you should revise up or down your settings depending on
the Cacti recommendation that you see once you start the installer.
```shell
[mysqld]
character_set_client = utf8mb4
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
max_allowed_packet = 16777777
max_heap_table_size = 500M
join_buffer_size = 32M
innodb_file_per_table = ON
innodb_buffer_pool_size = 500M
innodb_flush_log_at_trx_commit = 2
log-error = /var/log/mysql/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log = 1
slow-query-log-file = /var/log/mysql/mysql-slow.log
```
If using MariaDB 11.0 or higher, use the settings below:
```shell
[mariadb]
character_set_client = utf8mb4
character_set_server = utf8mb4
collation_server = utf8mb4_unicode_ci
max_heap_table_size = 500M
join_buffer_size = 32M
innodb_buffer_pool_size = 8G
innodb_doublewrite = OFF
tmp_table_size = 500M
log-error = /var/log/mysql/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log = 1
slow-query-log-file = /var/log/mysql/mysql-slow.log
```
2. Restart MySQL/MariaDB service to pick up the changes
```console
systemctl restart mysql
```
3. Populate timezone table with available timezones
```console
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
```
#### Setup Cacti database
1. Login to MySQL/MariaDB as root to create Cacti database
```console
# mysql -u root -p
MariaDB [(none)]> create database if not exists cacti;
Query OK, 1 row affected (0.00 sec)
```
2. Import Cacti database from SQL file
```sql
MariaDB [(none)]> use cacti;
Database changed
MariaDB [(cacti)]> source /usr/share/nginx/html/cacti/cacti.sql
```
3. Grant Cacti username access to Cacti database. Replace `your_cacti_username`
and `your_cacti_password` with your own details.
```sql
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cacti.* TO 'your_cacti_username'@'localhost' IDENTIFIED BY 'your_cacti_password';
Query OK, 0 rows affected (0.00 sec)
```
4. Grant cacti username to MySQL timezone table
```sql
MariaDB [(none)]> GRANT SELECT ON mysql.time_zone_name TO 'cacti'@'localhost';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
```
5. Save the Database Charset and Collation
```sql
MariaDB [(none)]> ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
MariaDB [(none)]> FLUSH PRIVILEGES;
```
### Common PHP packages
#### PHP
PHP and various packages are all required by Cacti for successful operation
1. Install PHP and required packages.
```console
dnf install -y php php-common php-bcmath php-cli \
php-mysqlnd php-gd php-gmp php-intl \
php-json php-ldap php-mbstring \
php-pdo php-pear php-snmp php-process \
php-xml php-zip php-fpm composer
```
---
Note: **php-fpm** is only required if your Web Server is Nginx
1. Set a timezone to your PHP.INI configuration
Edit php.ini, typically located at `/etc/php.ini`
```console
date.timezone = Pacific/Auckland
```
2. Disable insecure `cgi.fix_pathinfo`
```console
cgi.fix_pathinfo=0
```
#### Setup php-fpm
1. Enable and start the service to ensure it starts when the system reboots
```console
systemctl start php-fpm
systemctl enable php-fpm
```
2. Edit `/etc/php-fpm.d/www.conf`
Find `listen = 127.0.0.1:9000` and add the following line below
```console
listen = /var/run/php-fpm/php-fpm.sock
```
Find `listen.owner` and `listen.group` and set them to nginx
```console
listen.owner = nginx
listen.group = nginx
```
Find user and group and set them to `nginx`
```console
user = nginx
group = nginx
```
Restart php-fpm to pick up the changes
```console
systemctl restart php-fpm
```
### RRDtool
RRDtool is required to store the data retrieved from devices in `.rra` files to
produce the graphs which are shown within Cacti
```console
dnf install -y rrdtool
```
### SNMP
SNMP is used to query most devices for information.
```console
dnf install -y net-snmp net-snmp-utils
echo "rocommunity public" > /etc/snmp/snmpd.conf
systemctl enable snmpd
systemctl start snmpd
```
### Cacti
The following steps will show you how to manually download, install and
configure the basics for Cacti.
1. Download Cacti source code from
[Cacti Web Site](https://www.cacti.net/download_cacti.php)
```console
cd /tmp
wget https://www.cacti.net/downloads/cacti-1.y.z.tar.gz
tar -zxvf cacti-1.y.z.tar.gz
mv -v cacti-1.y.z /usr/share/nginx/html/cacti
```
2. Edit the config.php file
```console
mv -v /usr/share/nginx/html/cacti/include/config.php-dist /usr/share/nginx/html/cacti/include/config.php
```
3. Update database\_ fields with your own details. This section only applies to
the Main Cacti Server
```php
$database_type = 'mysql';
$database_default = 'your_cacti_database';
$database_hostname = 'localhost';
$database_username = 'your_cacti_username';
$database_password = 'your_cacti_password';
$database_port = '3306';
$database_ssl = false;
$database_ssl_key = '';
$database_ssl_cert = '';
$database_ssl_ca = '';
```
4. Set your cookie domain to match your web site domain name
```console
$cacti_cookie_domain = 'cacti.yourdomain.com';
```
5. Create your cron task file or systemd units file
Starting with Cacti 1.2.16, you have the option to use either the legacy
Crontab entry, or an optional cactid units file and server to run your Cacti
pollers.
For Crontab use, follow the instructions below:
Create and edit `/etc/cron.d/cacti` file. Make sure to setup the correct path
to poller.php
```console
*/5 * * * * nginx php /usr/share/nginx/html/cacti/poller.php &>/dev/null
```
For systemd unit's file install, you will need to modify the included units
file to following your install location and desired user and group's to run
the Cacti poller as. To complete the task, follow the procedure below:
```console
vim /var/www/html/cacti/service/cactid.service (edit the path)
touch /etc/sysconfig/cactid
cp -p /var/www/html/cacti/service/cactid.service /etc/systemd/system
systemctl enable cactid
systemctl start cactid
systemctl status cactid
```
The systemd units file makes managing a highly available Cacti setup a bit
more convenient.
#### Spine
1. Install the necessary packages to compile and install spine
```console
dnf install -y autoconf automake libtool dos2unix help2man \
openssl-devel mariadb-devel net-snmp-devel
```
2. Download spine source code from
[Cacti Web Site](https://www.cacti.net/spine_download.php)
Go to /tmp to download the source code and extract it
```console
cd /tmp
wget https://www.cacti.net/downloads/spine/cacti-spine-1.y.z.tar.gz
tar -zxvf cacti-spine-1.y.z.tar.gz
cd cacti-spine-1.y.z
```
3. Run the configure script and compile spine.
```console
# ./configure
# make & make install
config/install-sh -c -d '/usr/local/spine/bin'
/bin/sh ./libtool --mode=install /usr/bin/install -c spine '/usr/local/spine/bin'
libtool: install: /usr/bin/install -c spine /usr/local/spine/bin/spine
config/install-sh -c -d '/usr/local/spine/etc'
/usr/bin/install -c -m 644 spine.conf.dist '/usr/local/spine/etc'
config/install-sh -c -d '/usr/local/spine/share/man/man1'
/usr/bin/install -c -m 644 spine.1 '/usr/local/spine/share/man/man1'
```
4. Edit spine.conf
Rename spine.conf.dist to spine.conf
```console
mv -v /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
vi /usr/local/spine/etc/spine.conf
```
5. Now set up your database connection
```console
DB_Host localhost
DB_Database your_cacti_database
DB_User your_cacti_username
DB_Pass your_cacti_password
DB_Port 3306
#DB_UseSSL 0
#RDB_SSL_Key
#RDB_SSL_Cert
#RDB_SSL_CA
```
### Security Enhanced Linux (SELinux)
If you suspect SELinux is blocking Cacti, disable it temporarily to confirm, then re-enable it and apply the correct policy rather than leaving it disabled.
The [RHEL SELinux documentation](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/using_selinux/) covers policy management in depth and applies equally to Rocky Linux and AlmaLinux.
1. Check SELinux status
```console
getenforce
```
2. Disable SELinux temporarily for testing
```console
setenforce 0
```
3. Re-enable SELinux
```console
setenforce 1
```
4. Configure SELinux booleans for Cacti
Cacti requires two booleans so Nginx/PHP-FPM can reach the database and make outbound SNMP connections during polling:
```console
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_can_network_connect_db 1
```
5. Set file contexts (only needed if Cacti is outside `/usr/share/nginx/html`)
If you installed Cacti to a non-default path, apply the correct SELinux file contexts. The `semanage` command is provided by `policycoreutils-python-utils`; install it first if not already present:
```console
dnf install -y policycoreutils-python-utils
```
Replace `/path/to/cacti` with your actual install path:
```console
semanage fcontext -a -t httpd_sys_content_t "/path/to/cacti(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t "/path/to/cacti/rra(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t "/path/to/cacti/log(/.*)?"
restorecon -Rv /path/to/cacti
```
These labels grant the web server read access to Cacti's files and write access to the RRD and log directories. Without `httpd_sys_rw_content_t` on `rra/` and `log/`, graph generation silently fails even when UNIX permissions appear correct.
---
Copyright (c) 2004-2026 The Cacti Group
+45
View File
@@ -137,6 +137,51 @@ The system is now ready. Browse to
[http://serverip/cacti](http://serverip/cacti) to start the Cacti
initialization wizard.
### AppArmor Configuration
Ubuntu and Debian enable AppArmor by default, but they do not ship a
confinement profile for Apache, so on a stock system Apache runs unconfined
and no AppArmor changes are needed for Cacti. This section applies only if you
have deliberately installed and loaded an Apache profile (for example from the
`apparmor-profiles-extra` package).
First confirm whether an Apache profile is actually loaded:
```console
aa-status | grep apache2
ls /etc/apparmor.d/usr.sbin.apache2 2>/dev/null
```
If neither prints anything, Apache is unconfined and you can skip this section.
If a profile is present and denials appear in `/var/log/syslog` or `dmesg`:
```console
grep -i "apparmor.*DENIED" /var/log/syslog | grep -E "apache|php"
```
add a local override so Apache can reach the Cacti directories
(adjust the path if Cacti is not installed under `/var/www/html/cacti`):
```console
cat > /etc/apparmor.d/local/usr.sbin.apache2 << 'EOF'
# Cacti: allow Apache to read web root and write to RRD/log/cache dirs
/var/www/html/cacti/** r,
/var/www/html/cacti/rra/** rw,
/var/www/html/cacti/log/** rw,
/var/www/html/cacti/cache/** rw,
EOF
apparmor_parser -r /etc/apparmor.d/usr.sbin.apache2
systemctl restart apache2
```
Verify AppArmor is enforcing (not complaining) and no new denials appear:
```console
aa-status | grep apache2
grep -i "apparmor.*DENIED" /var/log/syslog | grep apache | tail -5
```
### Considerations when using proxies in front of Cacti (Cacti 1.2.23+)
For optimal security, specify only the HTTP headers that your proxy software
+1 -2
View File
@@ -113,8 +113,7 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details.
3.2. [Installation Under Enterprise Linux (RHEL/Rocky/AlmaLinux) - LEMP Stack](Install-Under-Enterprise-Linux-LEMP.md)
3.3.
[Installation Under Ubuntu/Debian - LAMP Stack](Installing-Under-Ubuntu-Debian.md)
3.3. [Installation Under Ubuntu/Debian - LAMP Stack](Installing-Under-Ubuntu-Debian.md)
4. [Installing Under Windows](Installing-Under-Windows.md)