cacti安装

准备

系统 centos7

更新yum

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

更新php到php7.2的包

参考链接  https://blog.csdn.net/qq_26917905/article/details/136607891
#安装Remi仓库的RPM包:
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm  -y
#安装yum-utils包:
yum install yum-utils -y
#启用Remi仓库中的PHP 7.2版本:
yum-config-manager --enable remi-php72

更新maridb 包

cat  > /etc/yum.repos.d/MariaDB.repo << EOF
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.6/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

EOF

安装

yum install -y epel-release
yum install -y nginx php-fpm mariadb-server mariadb php php-mysql php-gd php-xml php-mbstring php-snmp net-snmp net-snmp-utils rrdtool rrdtool-devel certbot python3-certbot-nginx wget mariadb-devel net-snmp-devel  php-gmp php-intl php-ldap php-posix

启动服务

systemctl enable --now nginx php-fpm mariadb 

下载并解压cacti ,并更改权限

# 目前版本为cacti-1.2.29
cd /var/www/html
wget https://www.cacti.net/downloads/cacti-latest.tar.gz
tar -zxvf cacti-latest.tar.gz
mv cacti-1.2.29/ cacti 
chown -R apache:apache /var/www/html/cacti/

创建数据库,并导入初始数据

mysql   #进入数据库
#下面命令在数据库中执行 
CREATE DATABASE cacti;
GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';
FLUSH PRIVILEGES;
EXIT;

# 导入cacti 初始化数据 
mysql -u cactiuser -p cacti < /var/www/html/cacti/cacti.sql

# 配置 Cacti 数据库连接
vi /var/www/html/cacti/include/config.php
里面配置不用改,我们是默认帐号和密码初始化的数据库

配置nginx

cat > /etc/nginx/conf.d/cacti.conf 
server {
    listen 80;
    server_name your-domain.com;

    root /var/www/html/;
    index index.php;

    location / {
        try_files $uri $uri/ index.php;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.ht {
        deny all;
    }
}

重启 Nginx 和 PHP-FPM

systemctl restart nginx php-fpm

开放端口

sed -i s@=enforcing@=disabled@ /etc/selinux/config
setenforce 0
firewall-cmd --add-port 80/tcp
firewall-cmd --add-port 80/tcp --permanent

导入时区

timedatectl set-timezone Asia/Shanghai
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql


mysql # 进入数据库 
GRANT SELECT ON mysql.time_zone_name TO 'cactiuser'@'localhost';
FLUSH PRIVILEGES;

安装spine

 yum -y install libtool automake help2man

wget https://files.cacti.net/spine/cacti-spine-1.2.29.tar.gz
cd cacti-spine-1.2.29/
./bootstrap
./configure
 make
make install
chown root:root /usr/local/spine/bin/spine
chmod u+s /usr/local/spine/bin/spine
cd /usr/local/spine/etc/
cp spine.conf.dist  spine.conf

初始化

http://127.0.0.1/cacti
默认帐号 密码 admin/admin 。登陆进去后会强制修改密码

如上图,会有一堆的配置不满足,逐个修改

cat /etc/php.ini |grep date.time
; http://php.net/date.timezone
;date.timezone =
date.timezone = Asia/Shanghai
memory_limit = 1280M
max_execution_time = 80

yum -y install php-gmp php-intl php-ldap php-posix



[root@bih_hk_cacti html]# cat /etc/my.cnf.d/server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]
collation_server = utf8mb4_unicode_ci
character_set_server = utf8mb4


max_allowed_packet = 16777216
max_heap_table_size = 384M
tmp_table_size = 384M
join_buffer_size = 6M
innodb_buffer_pool_size = 4096M
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
innodb_buffer_pool_instances = 9
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_doublewrite = OFF
#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
bind-address=127.0.0.1
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0

# this is only for embedded server
[embedded]

# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

# This group is only read by MariaDB-10.6 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.6]


yum -y install php-gmp php-intl php-ldap php-posix

timedatectl set-timezone Asia/Shanghai


posted @ 2025-03-17 16:05  lifei888  阅读(13)  评论(0)    收藏  举报