[cacti]nginx+php+cacti+mysql+php-fpm 安裝小記,cactinginx
網上教程很多,但是nginx不太多,下面安裝時候主要參考的篇文章:
http://54im.com/linux/linux-cacti-cn-install.html
http://www.tecmint.com/install-cacti-network-monitoring-on-rhel-centos-6-3-5-8-and-fedora-17-12/ 主要
http://tongcheng.blog.51cto.com/6214144/1627590 流水賬
http://better.blog.51cto.com/1886029/1199143 源碼安裝
用到的服務有mysql nginx net-snmp php acati php-fpm 還有各種安裝包,安裝的環境是 Centos6.5
我這邊一般的mysql nginx都是安裝好的,主要是php 安裝不熟悉
net-snmp, rrdtool 安裝
# yum install rrdtool net-snmp net-snmp-libs net-snmp-utils
php 以及依賴的包
# yum install php php-mysql php-snmp php-xml php-gd php-pear php-common php-devel php-mbstring php-cli php-fpm
mysql 使用者和資料庫建立
mysql>create database cacti default character set utf8;mysql>GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES, CREATE TEMPORARY TABLES, DROP, REFERENCES ON cacti.* TO cacti@'%' IDENTIFIED BY 'cacti#erya';mysql>flush privileges;
安裝cacti
# mkdir /www# cd /www/# wget -c http://www.cacti.net/downloads/cacti-0.8.8c.tar.gz# tar zxvf cacti-0.8.8c.tar.gz# mv cacti-0.8.8c cacti# mysql -ucacti -pcacti#erya -Dcacti < cacti/cacti.sql
修改資料庫配置
# vim /www/cacti/include/config.php
$database_type = "mysql";$database_default = "cacti";$database_hostname = "localhost";$database_username = "cacti";$database_password = "cacti#erya";$database_port = "3306";$database_ssl = false;
還有要改時區,否則畫出來的圖時間軸不對。還是php.ini設定的好
date.timezone = Asia/Shanghai
添加nginx web使用者和許可權,這裡沒做,不過可以後來修改
還有設定開機啟動等
添加nginx配置,重啟nginx php-fpm 等
server { listen 8080; server_name localhost; root /www/cacti; location /cacti { alias /www/cacti; index index.php; } location ~ ^/cacti.+\.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^/cacti(.+\.php)(.*)$; fastcgi_param SCRIPT_FILENAME /www/cacti/$fastcgi_script_name; include fastcgi.conf; }}
沒搞明白這個配置,但是可以使用
添加定時任務
#vim /etc/cron.d/cacti
*/5 * * * * /usr/bin/php /www/cacti/poller.php > /dev/null 2>&1
到這裡基本就安裝完畢了。
測試nginx ,php是否好用,這裡用fastcgi吧,只是介面
[root@MiWiFi-R1D html]# cat index.php<?phpphpinfo();?>
這裡的問題就是php怎麼啟動,nginx配置fastcgi很容易,但是php容器需要安裝和重新編譯
繼續安裝
# yum install php-fpm
這是一個服務,還需配置
主設定檔 /etc/php-fpm.conf 子設定檔在 php-fpm.d/
# /etc/init.d/php-fpm start正在啟動 php-fpm: [確定]
nginx設定檔
server { listen 8080; server_name localhost; root html; index index.php; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri =404; include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; } }
然後訪問 http://192.168.31.206:8080/可以看到php資訊,不太懂怎麼找到php檔案路徑的
錯誤
如果出現了下面的錯誤
2015/05/22 16:06:33 [error] 30521#0: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 523800 bytes) in /home/www/cacti/lib/adodb/adodb.inc.php on line 833" while reading response header from upstream, client: 103.254.64.163, server: localhost, request: "GET /cacti/index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "124.88.61.42:8890"
可能是沒有初始化資料庫的原因
聲明:
本文出自 “orangleliu筆記本” 部落格,轉載請務必保留此出處http://blog.csdn.net/orangleliu/article/details/45954663 作者orangleliu 採用署名-非商業性使用-相同方式共用協議