好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

nginx+php+cacti+mysql+php-fpm 安装小记

-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
  <?php 
phpinfo();
 ?>   

这里的问题就是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 采用署名-非商业性使用-相同方式共享协议

$(function () { $(‘pre.prettyprint code‘).each(function () { var lines = $(this).text().split(‘\n‘).length; var $numbering = $(‘ ‘).addClass(‘pre-numbering‘).hide(); $(this).addClass(‘has-numbering‘).parent().append($numbering); for (i = 1; i ‘).text(i)); }; $numbering.fadeIn(1700); }); });

[cacti]nginx+php+cacti+mysql+php-fpm 安装小记

标签:nginx   cacti   php   监控   运维   

查看更多关于nginx+php+cacti+mysql+php-fpm 安装小记的详细内容...

  阅读:29次