1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
|
# General Installing Instructions
Make sure the following packages are installed according to your operating
systems requirements. Verify, that httpd/apache and MySQL/MariaDB are started at
system startup.
## Required Packages for Most Operating Systems
Depending on your operating system and PHP version, certain packages are
required for Cacti. The largest variable in these requirements come with regard
to PHP and MySQL/MariaDB.
Installation requirements include the packages below. The installation of these
packages will vary by operating system.
### Base OS
- apache, IIS, or nginx
- net-snmp, net-snmp-utils
- rrdtool
- help2man (for spine)
- dos2unix (for spine)
- development packages (gcc, automake, autoconf, libtool, either mysql-devel or
mariadb-devel, net-snmp-devel, help2man)
(for spine)
### Database
MySQL versions to 5.7 are supported. MariaDB to 10.2 is also supported.
- mysql
- mysql-server
- libmysqlclient
or
- mariadb
- mariadb-server
- libmariadbclient
### PHP Modules
The installation of these modules vary by OS. Use the `php -m` command to verify
that they are installed.
- posix
- session
- sockets
- PDO
- pdo_mysql
- xml
- ldap
- mbstring
- pcre
- json
- openssl
- gd
- zlib
### PHP Optional Modules
The following modules are optional, but preferred to be installed.
- snmp
- gmp (for plugin support)
- com or dotnet (windows only)
### 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
```
## FreeBSD
When installing on FreeBSD you can use two ways. For both ways, cacti has a lot
of dependent packages, you don't need to install anything else. Everything is
prepared. Both ways have few pros and cons:
- Compiled packages - fast, but invariant dependencies (like older MySQL server,
PHP version, ...)
```sh
pkg install cacti
pkg install spine
```
- FreeBSD ports - compilation could last long time, but without invariant
dependencies (See
[Howto use ports](https://www.freebsd.org/doc/handbook/ports-using.html))
```sh
pkg install git
git clone https://git.FreeBSD.org/ports.git /usr/ports
git -C /usr/ports pull
cd /usr/ports/databases/mariadb106-server (or mysql80-server)
make install
cd /usr/ports/net-mgmt/cacti
make install
cd /usr/ports/net-mgmt/spine
make install
```
Apache and other software is possible install with package or Ports too.
Everything in FreeBSD is installed to /usr/local/ directory! In this
documentation you can see paths like /etc/php.ini, /usr/bin/spine, ...
Please use correct paths - /usr/local/etc, /usr/local/bin/spine, ...
For Spine set suid bit (without this isn't possible make ICMP ping):
```sh
chmod +s /usr/local/bin/spine
```
## Configure PHP
Verify that the modules are installed and configured correctly. There are
several ways to do so - consult
[PHP configuration instructions](http://www.php.net/manual/en/configuration.php)
for a complete description.
It is imperative that you set the `date.timezone` in your `/etc/php.ini`, or
`/etc/phpX/apache/php.ini` and `/etc/phpX/cli/php.ini` files. Failure to do so
will result in errors after the install is complete.
Most other PHP configuration is done automatically by the base OS, so there is
no need to discuss that here.
## Configure the Webserver (Apache)
Most Linux/UNIX OS' automatically configure the Web Server to allow PHP content.
So there should be no need to provide additional configuration. However, the
following section is included below for reference in the case that you are
running a UNIX version that does not properly configure the Webserver properly.
The documentation below is written specifically for RHEL and variants. So, the
instructions may vary.
Find the file `/etc/httpd/conf/httpd.conf` or its equivalent and make the
following changes to it:
```ini
# Load config files from the config directory "/etc/httpd/conf.d".
Include conf.d/*.conf
```
Now, locate the PHP configuration file at `/etc/httpd/conf.d/php.conf`
```ini
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
LoadModule php_module modules/libphp.so
#
# Cause the PHP interpreter to handle files with a .php extension.
AddHandler php-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
DirectoryIndex index.php
```
## Configure MySQL/MariaDB
Set a password for the root user, and record this password. If you loose control
of this password, you may have to re-install your database server in the case of
any system disaster or recovering from a crash.
```sh
shell> mysqladmin --user=root password somepassword
shell> mysqladmin --user=root --password reload
```
You must also load timezone information into the database. This is required for
various plugin use. Later, you will be required to grant access to the
`time_zone_name` table during the final installation steps.
```sh
shell> mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
```
Since Cacti 1.x is supporting internationalization (i18n), it is important that
the default character set for MySQL/MariaDB be i18n compatible. The Cacti
installer will make specific recommendations on MySQL/MariaDB settings. Follow
those as applicable for your OS.
Galera clustering: There are several tables which are set to use the MEMORY
storage engine which do not get replicated among nodes which can cause problems.
If you configure Cacti to only connect to one node of your cluster and are not
load balancing this does not apply to you.
If you are running multiple nodes in a load-balanced environment where you
connect to a VIP you should remove all but one node from rotation during Cacti
installation or update. After the installation/update login to your MySQL server
and execute the following commands to update those tables to use the InnoDB
engine:
```sql
MariaDB [(none)]> use cacti;
MariaDB [cacti]>> ALTER TABLE `automation_ips` ENGINE=InnoDB;
MariaDB [cacti]>> ALTER TABLE `automation_processes` ENGINE=InnoDB;
MariaDB [cacti]>> ALTER TABLE `data_source_stats_hourly_cache` ENGINE=InnoDB;
MariaDB [cacti]>> ALTER TABLE `data_source_stats_hourly_last` ENGINE=InnoDB;
MariaDB [cacti]>> ALTER TABLE `poller_output` ENGINE=InnoDB;
MariaDB [cacti]>> ALTER TABLE `poller_output_boost_processes` ENGINE=InnoDB;
```
These changes should replicate to the other nodes in your cluster. Allow Cacti
to run at least two or three full polling cycles before placing the other nodes
back into rotation.
## Install and Configure Cacti
1. Extract the distribution tarball.
```sh
shell> tar xzvf cacti-version.tar.gz
```
2. Create the MySQL database:
```sh
shell> mysqladmin --user=root create cacti
```
3. Import the default cacti database:
```sh
shell> mysql cacti < cacti.sql
```
4. Optional: Create a MySQL username and password for Cacti.
```sql
shell> mysql --user=root mysql
mysql> CREATE DATABASE cacti
mysql> CREATE USER 'cacti'@'localhost';
mysql> ALTER USER 'cacti'@'localhost' IDENTIFIED BY 'somepassword';
mysql> GRANT ALL PRIVILEGES ON cacti.* to 'cacti'@'localhost';
mysql> GRANT SELECT ON mysql.time_zone_name TO 'cacti'@'localhost';
mysql> FLUSH PRIVILEGES;
```
Note that if your `root` (or equivalent) user does not have `SUPER`
permissions, it may still be possible to `GRANT SELECT` privileges to the
Cacti user via an `INSERT INTO mysql.tables_priv`.
```sql
INSERT INTO mysql.tables_priv (Host, Db, User, Table_name, Grantor, Table_priv)
VALUES ('localhost', 'mysql', 'cactiuser', 'time_zone_name', 'root@localhost', 'Select');
```
5. Edit `include/config.php` and specify the database type, name, host, user and
password for your Cacti configuration.
```php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";
```
6. Set the appropriate permissions on Cacti's directories for graph/log
generation. You should execute these commands from inside Cacti's directory
to change the permissions.
```sh
shell> chown -R cactiuser rra/ log/ cache/
```
(Enter a valid username for _cactiuser_, this user will also be used in the
next step for data gathering.)
7. 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 <path_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 <path_cacti>/service/cactid.service (edit the path)
touch /etc/sysconfig/cactid
cp -p <path_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.
8. During install, you will need to provide write access to the following files
and directories:
```sh
shell> chown -R resource scripts include/config.php
```
Once the installation is complete, you may change the permissions to more
restrictive settings.
9. Point your web browser to:
`http://<your-server>/cacti/`
Log in the with a username/password of _admin_. You will be required to
change this password immediately. Make sure to fill in all of the path
variables carefully and correctly on the following screen.
## (Optional) Install and Configure Spine
Spine is a very fast data collection engine, written in C. It is an optional
replacement for cmd.php. If you decide to use it, you will have to install it
explicitly. It does not come with cacti itself.
The easiest way is to install Spine using rpm or ports. You will find packages
for Spine at the main cacti site or from your distribution.
To compile Spine, download it to any location of your liking. Then, issue from
the downloaded directory following commands
```sh
shell>./bootstrap
```
If the `bootstrap` script is successful, you then will follow the instructions it
provides to compile and install.
Assuming, you've managed to install spine correctly, you will have to configure
it. The configuration file may be placed in the same directory as spine itself
or at /etc/spine.conf.
```ini
DB_Host 127.0.0.1 or hostname (not localhost)
DB_Database cacti
DB_User cactiuser
DB_Password cacti
DB_Port 3306
```
### Considerations when using Proxys 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
```php
/*
* 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;
```
---
Copyright (c) 2004-2024 The Cacti Group
|