Cacti on nginx + php-fpm

Cacti on nginx + php-fpm

系统环境:

centos 5.3  32位     #(安装好所有的开发工具)

软件版本:

Cacti-0.8.7e

Mysql-5.1.38

php-5.2.10

php-5.2.10-fpm-0.5.13.diff.gz

rrdtool-1.2.28

nginx-0.8.15

rpmforge-release.i386

rpmforge

yum -y install rpmforge-release           #安装yum的rpmforge仓库

Mysql-5.1.38

cd /home

wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.38.tar.gz/from/http://mysql.isu.edu.tw/

tar -xvf mysql-5.1.38.tar.gz              #从mysql官网下载源码包,解压

进入mysql解压目录

cd /home/mysql-5.1.38

下为mysql 官网提供的编译配置

       -fno-exceptions -fno-rtti" ./configure        --prefix=/usr/local/mysql --enable-assembler        --with-mysqld-ldflags=-all-static建议移除最后1排;CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors        -fno-exceptions -fno-rtti" ./configure        --prefix=/usr/local/mysql --enable-assembler Make

Make install              #这样mysql就被安装在 /usr/local/mysql 之下

====================================================================

configure: error: No curses/termcap library found 的错误解决方法

在编译Mysql时

./configure –prefix=DIR

configure: error: No curses/termcap library found

说明 curses/termcap 库没有安装    apt-cache search curses | grep lib

安装 libncurses5-dev ,然后重新运行配置

apt-get install libncurses5-dev

上边的具体细节还希望先yum list | grep ncurses下看看。

yum install ncurses-dev

没有安装gcc的也要yum install gcc下先,不然不会编译。

====================================================================

cp /home/mysql-5.1.38/support-files/my-medium.cnf /etc/my.cnf 

#将预置的配置文件拷贝至/etc下

cp /usr/local/mysql/bin/* /usr/bin/ 

#将mysql所有可执行文件拷贝至/usr/bin/下

groupadd mysql                                     #系统添加 mysql 组useradd -g mysql mysql                #系统添加 mysql 用户至mysql 组cd /usr/local/mysqlchown -R mysql .  #将/usr/local/mysql下所有文件,目录的所有者改mysqlchgrp -R mysql . #将/usr/local/mysql下所有文件,目录的所有者改为 mysql          (后面还有个点哦,看清楚)mysql_install_db --user=mysql                   #安装数据库mysqld_safe --user=mysql &                      #启动mysql服务cp /home/mysql-5.1.38/support-files/mysql.server /etc/init.dchmod 755 /etc/init.d/mysql.serverchkconfig --add mysql.serverchkconfig mysql.server on      #以系统服务的方式启动mysql servermysql -u root                   #以root用户进入mysql命令行在mysql命令行下执行   DROP USER '';                         #移除anonymousSET PASSWORD FOR 'root'@'localhost'= PASSWORD('密码');  #设置在localhost主机上root帐号的密码SET PASSWORD FOR 'root'@'127.0.0.1'= PASSWORD('密码');  #设置在localhost主机上root帐号的密码=================================================================ERROR 1045 (28000): Access denied for user 'root'@'localhost'(using password: NO)错误的解决方法:方法一:# /etc/init.d/mysql stop# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &# mysql -u root mysqlmysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';mysql> FLUSH PRIVILEGES;mysql> quit# /etc/init.d/mysql restart# mysql -uroot –pEnter password: <输入新设的密码newpassword>mysql>方法二:

C:Program FilesMySQLMySQL Server 5.0in>mysql -u root –p

Enter password: ******

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 28 to server version: 5.0.24a-community-nt

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

=================================================================php-5.2.10 and php-5.2.10-fpm

cd /home

wget http://cn.php.net/get/php-5.2.10.tar.bz2/from/this/mirror

tar -xvf php-5.2.10.tar.bz2       #从php官网下载源码包,解压

cd /home

wget http://php-fpm.org/downloads/php-5.2.10-fpm-0.5.13.diff.gz

#从php-fpm.org官网下载源码包

gzip -cd php-5.2.10-fpm-0.5.13.diff.gz | patch -d php-5.2.10 -p1#给php-5.2.10 打上php-fpm补丁yum -y install gd.i386 gd-devel.i386yum -y install libmcrypt.i386 libmcrypt-devel.i386yum -y install libmhash.i386 libmhash-devel.i386#用yum安装php所需要的库cd /homewget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.tar.gztar-xvf libiconv-1.13.tar.gzcd /home/libiconv-1.13./configure --prefix=/usr/local/libiconvmakemake install                    #手动下载编译安装libiconv库cd /home/php-5.2.10./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pearmakemake install                                   #编译安装phpcp /home/php-5.2.10/php.ini-dist /usr/local/php5/etc/php.ini#拷贝预置配置文件至php安装目录vim /usr/local/php5/etc/php.ini查找cgi.fix_pathinfo删除前面的注释 修改为cgi.fix_pathinfo=1注释掉doc_root ==================================================================groupadd nginxuseradd -g nginx nginxvim /usr/local/php5/etc/php-fpm.conf 修改第63行,66行 .63   .66         删除注释符,将nobody改为nginx  .63    nginx.66    nginx#添加web用户组nginx,用户nginx 将php-fpm的运行用户组和用户修改为nginxcp /usr/local/php5/sbin/php-fpm /sbin/php-fpmphp-fpm start                                  #启动php-fpm=================================================================CentOS 5 常见的configure error的解决方法仅限于CentOS 5

configure: error: No curses/termcap library foundyum -y install ncurses-develdebian: apt-get install libncurses5-devconfigure: error: xml2-config not foundyum -y install libxml2-develdebian:apt-get install libxml2-devconfigure: error: Cannot find OpenSSL'syum -y install openssl-develconfigure: error: libjpeg.(a|so) not foundyum -y install gdyum -y install gd-develdebian:apt-get install libjpeg-devconfigure: error: libpng.(a|so) not found.apt-get install libpng12-devconfigure: error: cannot find output from lex; giving upyum -y install flexconfigure: error: mod_deflate has been requested but can not be built due to prerequisite failuresyum -y install zlib-devel openssl-develdebian:apt-get install zlib1g-devconfigure: error: libXpm.(a|so) not found.apt-get install libxpm-devonfigure: error: freetype.h not found.apt-get install libfreetype6-devconfigure: error: ...No recognized SSL/TLS toolkit detectedapt-get install libssl-devconfigure: error: Cannot find ldap.hyum install openldap-develconfigure: error: Please reinstall libmhash - I cannot find mhash.hyum install mhash-devel=================================================================Nginxyum -y install pcre-devel.i386   #安装nginx需要的正则表达式库头cd /homewget http://sysoev.ru/nginx/nginx-0.8.15.tar.gztar-xvf nginx-0.8.15.tar.gzcd /home/nginx-0.8.15./configure  --user=nginx --group=nginxmakemake installcp /usr/local/nginx/sbin/nginx /sbin/            #安装nginx vim /usr/local/nginx/conf/nginx.conf  #编辑nginx.conf加入以下配置    server {        listen 80;              location / {               index    index.html index.htm index.php;             }         location ~* .php {          fastcgi_pass 127.0.0.1:9000;          fastcgi_index index.php;          include fastcgi_params;          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;             } }Cacti + Cacti spinecd /home

wget http://www.cacti.net/downloads/cacti-0.8.7e.tar.gz

wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.7e.tar.gz

tar -xvf  cacti-0.8.7e.tar.gz

tar -xvf  cacti-spine-0.8.7e.tar.gz    #从官网下载cacti 及spine 解压yum -y install net-snmp.i386 net-snmp-devel.i386 net-snmp-libs.i386 net-snmp-utils.i386                    #通过yum安装net-snmp相关组件

mkdir /var/wwwmv /home/cacti-0.8.7e /var/www/cacti#将cacti相关文件移动至新建web目录groupadd cactiuseradd -g cacti cacti                        #新建cacti用户,用户组chown -R cacti:cacti /var/www/cacti/rra/ /var/www/cacti/log/#更改cacti目下 rra/ log/ 2个目录的所有者chmod 777 /var/www/cacti/rra -Rchmod 777 /var/www/cacti/log -R#更改cacti目录下rra/ log/ 2个目录及目录下的读写权限cd /var/www/cacti         mysqladmin --user=root -p create cacti   #创建名为cacti的数据库mysql -p cacti < /var/www/cacti/cacti.sql  #将cacti安装目录下的数据库数据导入到系统新建的cacti数据库中mysql --user=root mysql                 #以root用户进入mysql数据库

GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY '密码';

flush privileges;        #给系统用户cacti 添加cacti数据库的所有权限vi /var/www/cacti/include/config.php

#将预设配置中的相关选项修改为 上面的相关配置

如:

$database_type = "mysql";

$database_default = "cacti";$database_hostname = "localhost";$database_username = "cactiuser";$database_password = "cacti";改为:

$database_type = "mysql";$database_default = "cacti";$database_hostname = "localhost";$database_username = "cacti数据库的用户名";$database_password = "cacti数据库的密码";vi /etc/crontab

添加

*/5 * * * * 用户名 /usr/local/php5/bin/php /var/www/cacti/poller.php --force > /dev/null 2>&1

service crond restart                 #如果刷不出图可在上面加 --force 

vi /usr/local/nginx/conf/nginx.conf

root /var/www/cacti;                 #修改web根目录至 /var/www/cacti

修改

location ~* .php {astcgi_pass 127.0.0.1:9000;   fastcgi_index index.php;          include fastcgi_params;   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;             }改为:

location ~* .php {fastcgi_pass 127.0.0.1:9000;    fastcgi_index index.php;          include fastcgi_params;     fastcgi_param SCRIPT_FILENAME /var/www/cacti$fastcgi_script_name;             }nginx               
 #启动Nginx服务

=====================================================================

nginx配置httpd服务遇到问题No input file specified的解决

首先php.ini的配置中

cgi.fix_pathinfo=1

doc_root=

doc_root曾经被我设置过一个路径,结果php老提示“No input file specified.”,只有一个虚机好使。改掉后就正常了。

nginx中的配置有些麻烦

fastcgi_pass 127.0.0.1:1234;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;

每个虚机要根据自己不通的虚机设置不不同的目录,要保证这个路径正确。

fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;不能在fastcgi_pass 127.0.0.1:1234;的前面。

跟我的情况很类似 我也尝试改了一下第二个vhost的文件中php部分:

# .php

location ~ .*.(php|php5)?$
{
    #fastcgi_pass unix:/tmp/php-cgi.sock;

    fastcgi_pass 127.0.0.1:9000;

    fastcgi_param  SCRIPT_FILENAME  /data/htdocs/域名/$fastcgi_script_name; 确实是要与第一个域名区分开来

    fastcgi_index index.php;

    #include fcgi.conf;

}

=====================================================================

nginx时常被php的“No input file specified.

首先php.ini的配置中

cgi.fix_pathinfo=1

doc_root=

doc_root曾经被我设置过一个路径,结果php老提示“No input file specified.”,只有一个虚机好使。改掉后就正常了。

nginx中的配置有些麻烦

fastcgi_pass 127.0.0.1:1234;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;

每个虚机要根据自己不通的虚机设置不能的目录,要保证这个路径正确。

fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;不能在fastcgi_pass 127.0.0.1:1234;的前面。

记得修改了php.ini要重启fastcgi服务。

其实都是因为粗心造成的,本来很简单,写出来也给自己提个醒

=====================================================================

RRDTool(两种方法):

1.软件包安装:

先yum安装所要的库文件:

yum install cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel

然后下载rrdtool包,安装:

wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.1.tar.gz

tar -zxvf rrdtool-1.3.1.tar.gz

./configure --prefix=/usr/local/rrdtool

make

make install

2. 另一种yum安装

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum -y install rrdtool*

配置开机自动启动Nginx + PHP

vi /etc/rc.local

在末尾增加以下内容:

ulimit -SHn 51200

/usr/local/webserver/php/sbin/php-fpm start

/usr/local/webserver/nginx/sbin/nginx

重启服务器

WEB界面配置Cacti

之后就可通过访问服务器ip 进去cacti界面

一路默认配置进入密码验证界面

Username:admin

Password:admin

 Cacti on nginx + php-fpm_第1张图片

进入Cacti界面

单击setting选项

在General选项卡里将RRDTool Utility Version那一项改为RRDTool 1.3.X


在Ppaths选项卡里将所有带红色的路径都全设置一遍,直到没有红色为止

我的是这两项:

Cacti on nginx + php-fpm_第2张图片 


PHP Binary Path→/usr/local/php5/bin/phpRRDTool Binary Path→/usr/local/rrdtool/bin/rrdtool好了,点击保存就可以体验自己的千辛万苦做出来的东东了。

你可能感兴趣的:(Cacti on nginx + php-fpm)