一.建立一個虛拟主機
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個資料源進行監控。