一.建立一个虚拟主机
1.vim /etc/httpd/conf.d/vhost.conf
该文件为新建文件,也可在/etc/httpd/conf/httpd.conf末尾添加,为:
<VirtualHost 192.168.18.144:80> /固定格式 ip和端口自己设置
ServerName cacti.gaowei.com /域名
DocumentRoot /web/vhost/cacti-0.8.8a /路径
<Directory "/web/vhost/cacti-0.8.8a"> /固定格式,“”里边为路径
Options Indexes FollowSymLinks /一些权限,百度可查
AllowOverride None
Order allow,deny
Allow from all
</Directory> /固定格式
ErrorLog "logs/cacti-error_log" /报错日志
CustomLog "logs/cacti-access_log" common /常规日志
</VirtualHost> /固定格式
2.vim /etc/hosts 添加:
192.168.18.144 cacti.gaowei.com
二.安装cacti
1.tar xvf cacti-0.8.8a -C /web/vhost/ //web/vhost为自己创建的
cd /web/vhost/cacti-0.8.8a
2.mysqladmin create cactidb /创建mysql数据库
3.mysql cactidb < cacti.sql /将cacti.sql导入到数据库
4.mysql -e "GRANT ALL ON cactidb1.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser'" /cactidb给用户cactiuser所有权限
密码为cactiuser
5.mysqladmin flush-privileges /刷新
6.mysql -ucactiuser -p /以cactiuser用户登录
7.mysql>SHOW DATABASES; /查看创建的数据库
8.cd include ;vim config.php /修改如9
9.
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";
$database_ssl = false;
/*
Edit this to point to the default URL of your Cacti install
ex: if your cacti install as at http://serverip/cacti/ this
would be set to /cacti/
*/
//$url_path = "/cacti/";
$url_path = "/";
10.service httpd restart
11.useradd cactiuser ;passwd cactiuser
12.chown -R cactiuser:cactiuser rra/ log/
13.vim /etc/php.ini /修改如14
14.这个选项设置为date.timezone = Asia/Shanghai
15.echo '*/5 * * * * /usr/bin/php /web/vhost/cacti-0.8.8a/poller.php &>/dev/null' > /var/spool/cron/cactiuser /每隔5分钟cactiuser用户会执行
poller.php
16.crontab -u cactiuser -e /使15写入成功,如果有错,则会报错
17.在浏览器输入
cacti.gaowei.com 会弹出cacti安装提示。按提示安装即可,自带5个数据源,可添加本机对这5个数据源进行监控。
转载于:https://blog.51cto.com/xiaoaojxh/1945371