在 CentOS 上安装 Cacti 数据库,你需要先安装 LAMP(Linux、Apache、MySQL 和 PHP)环境,然后再安装 Cacti
sudo yum update -y
sudo yum install httpd -y
启动 Apache 服务并设置开机启动:
sudo systemctl start httpd
sudo systemctl enable httpd
创建一个新的 Apache 虚拟主机配置文件:
sudo vi /etc/httpd/conf.d/cacti.conf
将以下内容粘贴到文件中,然后保存并退出:
<VirtualHost *:80>
ServerName cacti.example.com
DocumentRoot /var/www/html/cacti
<Directory "/var/www/html/cacti">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/cacti-error.log
CustomLog ${APACHE_LOG_DIR}/cacti-access.log combined
</VirtualHost>
重启 Apache 服务以应用更改:
sudo systemctl restart httpd
sudo yum install mariadb-server mariadb -y
启动 MySQL 服务并设置开机启动:
sudo systemctl start mariadb
sudo systemctl enable mariadb
运行安全安装脚本来配置 MySQL:
sudo mysql_secure_installation
按照提示操作,设置 root 密码并删除匿名用户等。
sudo mysql -u root -p
输入 root 密码后,创建一个新数据库:
CREATE DATABASE cacti;
创建一个新用户并授权访问数据库:
CREATE USER 'cacti'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON cacti.* TO 'cacti'@'localhost';
FLUSH PRIVILEGES;
EXIT;
cd /var/www/html
sudo wget https://repo.cacti.org/cacti/1.2.4/apache2/cacti-1.2.4-apache2.tar.gz
sudo tar xvf cacti-1.2.4-apache2.tar.gz
sudo mv cacti-1.2.4-apache2 /var/www/html/cacti
sudo cp /var/www/html/cacti/config/config.php.sample /var/www/html/cacti/config/config.php
sudo vi /var/www/html/cacti/config/config.php
找到以下行并进行修改:
$database['host'] = 'localhost';
$database['user'] = 'cacti';
$database['pass'] = 'your_password';
$database['dbname'] = 'cacti';
保存并退出。
sudo chown -R apache:apache /var/www/html/cacti
sudo chmod -R 755 /var/www/html/cacti/include
sudo chmod -R 755 /var/www/html/cacti/plugins
http://your_server_ip/cacti
来访问 Cacti 的安装向导。按照向导完成安装过程。注意:请将上述示例中的 your_password
替换为你自己的密码,并将 cacti.example.com
替换为你的域名或服务器 IP 地址。