logje 发表于 2013-5-14 09:05:12

安装配置Cacti+Nginx+PHP+MYSQL

本实验在CentOS release 5.7上完成的,所有的软件均是目前(2013.04.15)最新的!所需要的软件包在这里:http://down./data/764169本文来自http://better.blog./1、安装Nginx源码包存放目录# cd /usr/local/src/上传源码包# rz安装编译工具及依赖库# yum install gcc gcc-c++ automake autoconf libtool make安装PCRE库# tar -zxvf pcre-8.32.tar.gz# cd pcre-8.32# ./configure && make && make install安装zlib库# tar -zxvf zlib-1.2.7.tar.gz# cd zlib-1.2.7# ./configure && make && make install解压缩openssl源码包,不用安装仅仅用于安装nginx时指定关联文件# tar -zxvf openssl-1.0.1c.tar.gz安装nginx# tar -zxvf nginx-1.2.8.tar.gz# cd nginx-1.2.8# ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.32 --with-zlib=/usr/local/src/zlib-1.2.7 --with-openssl=/usr/local/src/openssl-1.0.1c# make && make install加入开机启动脚本# vim /etc/init.d/nginx
#!/bin/sh## nginx - this script starts and stops the nginx daemon## chkconfig: 345 85 15# description: Nginx is an HTTP(S) server, HTTP(S) reverse# proxy and IMAP/POP3 proxy server# processname: nginx# config: /usr/local/nginx/nginx.conf# pidfile: /usr/local/nginx/nginx.pid# Source function library.. /etc/init.d/functions# Source networking configuration.. /etc/sysconfig/networkif [ -f /etc/sysconfig/nginx ];then. /etc/sysconfig/nginxfi# Check that networking is up.[ "$NETWORKING" = "no" ] && exit 0nginx="/usr/local/nginx/nginx"prog=$(basename $nginx)NGINX_CONF_FILE="/usr/local/nginx/nginx.conf"[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginxlockfile=/var/lock/subsys/nginxstart() {[ -x $nginx ] || exit 5[ -f $NGINX_CONF_FILE ] || exit 6echo -n $"Starting $prog: "daemon $nginx #-c $NGINX_CONF_FILEretval=$?echo[ $retval -eq 0 ] && touch $lockfilereturn $retval}stop() {echo -n $"Stopping $prog: "killproc $prog -QUITretval=$?echo[ $retval -eq 0 ] && rm -f $lockfilereturn $retvalkillall -9 nginx}restart() {configtest || return $?stopsleep 1start}reload() {configtest || return $?echo -n $"Reloading $prog: "killproc $nginx -HUPRETVAL=$?echo}force_reload() {restart}configtest() {$nginx -t #-c $NGINX_CONF_FILE}rh_status() {status $prog}rh_status_q() {rh_status >/dev/null 2>&1}case "$1" instart)rh_status_q && exit 0$1;;stop)rh_status_q || exit 0$1;;restart)$1;;test)configtest;;reload)rh_status_q || exit 7$1;;force-reload)force_reload;;status)rh_status;;condrestart|try-restart)rh_status_q || exit 0;;*)echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|test}"exit 2esac

修改执行权限# chmod 755 /etc/init.d/nginx启动服务# service nginx start打开网页查看是否成功http://192.168.137.20/到此nginx配置完成参考链接:http://www.nginx.cn/install2、安装PHP集成在nginx源码包存放目录# cd /usr/local/src/上传源码包# rz由于光盘里面有几个依赖库没有所以还要用到互联网上的epel源# wget http://dl.fedoraproject.org/pub/ ... ease-5-4.noarch.rpm# rpm -ivh epel-release-5-4.noarch.rpm安装编译工具及依赖库# yum install gcc automake autoconf libtool make gcc-c++ glibc libxml2 libxml2-devel curlpp curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel mhash-devel libxslt-devel bzip2 bzip2-devel# tar -zxvf php-5.4.14.tar.gz# cd php-5.4.14# ./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-gd# make && make install# cp php.ini-production /usr/local/php/lib/php.ini# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm# vim /etc/init.d/php-fpm增加如下# chkconfig: 345 84 16# chmod 755 /etc/rc.d/init.d/php-fpm修改nginx配置文件使其支持fastcgi# vim /usr/local/nginx/nginx.conf
location / {root html;index index.php index.html index.htm;}location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}

设置时区# vim /usr/local/php/lib/php.ini找到date.timezone去掉注释并修改如下date.timezone = "Asia/Chongqing"新建一个测试页面# vim /usr/local/nginx/html/index.php<?phpphpinfo();?>启动服务# service php-fpm start# service nginx restart访问测试http://192.168.137.20/
这里面的内容在指定http://php-fpm.org/wiki/Features参考链接:http://www.nginx.cn/231.html3、安装MYSQL源码包存放目录# cd /usr/local/src/上传源码包# rz安装编译工具及依赖库# yum install ncurses libaio gcc gcc-c++ perl ncurses-devel bison安装cmake编译工具# tar -zxvf cmake-2.8.10.2.tar.gz# cd cmake-2.8.10.2# ./configure && make && make install安装mysql# groupadd mysql# useradd -g mysql -s /sbin/nologin mysql# mkdir -p /data/mysql# chown -R mysql:mysql /data/mysql# tar -zxvf mysql-5.6.11.tar.gz# cd mysql-5.6.11# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc# make && make install# cp ./support-files/my-default.cnf /etc/my.cnf# vim /etc/my.cnf修改下面内容basedir = /usr/local/mysqldatadir = /data/mysql# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld# chmod 755 /etc/rc.d/init.d/mysqld# vim /etc/rc.d/init.d/mysqld修改下面内容basedir=/usr/local/mysqldatadir=/data/mysql# chkconfig mysqld on# chown mysql:mysql . -R# chmod 755 ./scripts/mysql_install_db# ./scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql# service mysqld start# /usr/local/mysql/bin/mysql -uroot –pmysql> show databases;4、安装rrdtool源码包存放目录# cd /usr/local/src/上传源码包# rz安装依赖库# yum install cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel编译安装rrdtool# tar -zxvf rrdtool-1.4.7.tar.gz# cd rrdtool-1.4.7# ./configure --prefix=/usr/local/rrdtool && make && make install5、安装snmp# yum install net-snmp-utils php-snmp net-snmp-libs# vim /etc/snmp/snmpd.conf# chkconfig snmpd on注释掉下面2行#view systemview included .1.3.6.1.2.1.1#view systemview included .1.3.6.1.2.1.25.1.1增加如下一行view systemview included .1完整配置文件如下
com2sec notConfigUser default publicgroup notConfigGroup v1 notConfigUsergroup notConfigGroup v2c notConfigUserview systemview included .1access notConfigGroup "" any noauth exact systemview none nonesyslocation Unknown (edit /etc/snmp/snmpd.conf)syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat

6、安装cacti源码包存放目录# cd /usr/local/src/上传源码包# rz开始安装# useradd -g users -s /sbin/nologin cactiuser# tar -zxvf cacti-0.8.8a.tar.gz# cp cacti-0.8.8a /usr/local/nginx/html/cacti –rf创建cacti数据库# cd /usr/local/mysql/bin/# ./mysqladmin --user=root create cacti# ./mysql cacti < /usr/local/nginx/html/cacti/cacti.sql# ./mysql --user=root mysqlmysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY '123456';mysql> flush privileges;mysql> \q编辑配置文件# vim /usr/local/nginx/html/cacti/include/config.php$database_type = "mysql";$database_default = "cacti";$database_hostname = "localhost";$database_username = "cactiuser";$database_password = "123456";$database_port = "3306";$database_ssl = false;# cd /usr/local/nginx/html/cacti/# chown -R cactiuser rra/ log/# cd scripts/# chown cactiuser:users *# crontab -u cactiuser –e*/1 * * * * /usr/local/php/bin/php /usr/local/nginx/html/cacti/poller.php > /dev/null 2>&1打开浏览器进行初始化安装(第一次登录默认密码帐号admin密码admin)http://192.168.137.20/cacti/以下内容可忽略,将会在下一次笔记时详细解释排错# /usr/local/rrdtool/bin/rrdtool fetch localhost_load_1min_5.rrd AVERAGE# snmpwalk -v2c -c public 192.168.137.20重置管理员密码http://wiki.yepn.net/cactishell> mysql -u root -p cactimysql> update user_auth set password=md5('admin') where username='admin';Cacti清除日志cat /dev/null > cacti.log修改轮询时间及绘图时间安装cacti-spine支持快速轮询http://skyou.blog./2915693/544914# yum install net-snmp-devel# tar -zxvf cacti-spine-0.8.8a.tar.gz# cd cacti-spine-0.8.8a# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18# ./configure --prefix=/usr/local/cacti-spine --with-snmp=/usr# make && make install# cp spine.conf.dist /etc/spine.conf# vim /etc/spine.conf# /usr/local/cacti-spine/bin/spineSPINE: Using spine config file SPINE: Version 0.8.8a startingSPINE: Time: 0.1390 s, Threads: 4, Hosts: 3进入http://192.168.137.20/设置cacti,选择spine轮询机制运行PathsPollerCron# crontab -u cactiuser -e*/1 * * * * /usr/local/php/bin/php /usr/local/nginx/html/cacti/poller.php > /dev/null 2>&1选中Data Templates → Unix - Logged in Users → 重建轮询缓存# /usr/local/php/bin/php -q /usr/local/nginx/html/cacti/cli/rebuild_poller_cache.php -d参考链接Cacti安装配置的详细步骤http://www.mysqlops.com/2011/06/08/cacti-install-setting.htmlRedHat / CentOS Install and Configure Cacti Network Graphing Toolhttp://www.cyberciti.biz/faq/fedora-rhel-install-cacti-monitoring-rrd-software/Install and Configure Cactihttp://www.cacti.net/downloads/docs/html/unix_configure_cacti.htmlInstall RRDTool on Red Hat Enterprise Linuxhttp://www.cyberciti.biz/faq/howto-install-rrdtool-on-rhel-linux/Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建)http://www.osyunwei.com/archives/3209.htmlChapter 1. Installing MySQL from Sourcehttp://dev.mysql.com/doc/mysql-sourcebuild-excerpt/5.6/en/source-installation.htmlDownload, Configure, Compile, And Install MySQL 5.6http://www.geeksww.com/tutorials/database_management_systems/mysql/installation/download_configure_compile_and_install_mysql_56.phpError Headerhttp://php-fpm.org/wiki/Features实战Nginx与PHP(FastCGI)的安装、配置与优化http://ixdba.blog./2895551/806622Nginx安装http://www.nginx.cn/installnginx php-fpm安装配置http://www.nginx.cn/231.htmlCentOS 6.3下MySQL 5.6源码安装http://database./art/201304/388452.htmChapter 2. Installing MySQL from a Standard Source Distributionhttp://dev.mysql.com/doc/mysql-sourcebuild-excerpt/5.6/en/installing-source-distribution.htmlChapter 4. MySQL Source-Configuration Optionshttp://dev.mysql.com/doc/mysql-sourcebuild-excerpt/5.6/en/source-configuration-options.htmlInstalling RRDToolhttp://martybugs.net/linux/rrdtool/

ck1987 发表于 2013-5-14 09:55:19

不在放荡中变坏,就在沉默中变态!

jjfjjj 发表于 2013-5-16 08:48:06

爱——不是想出来的,爱——是做出来的!!

284354749 发表于 2013-5-17 06:51:36

不错不错,楼主您辛苦了。。。

鄂破机看 发表于 2013-5-17 21:34:51

睡眠是一门艺术——谁也无法阻挡我追求艺术的脚步!

gbless 发表于 2013-5-18 12:21:58

女,喜甜食,甚胖!该女有一癖好:痛恨蚂蚁,见必杀之。问其故曰:这小东西,那么爱吃甜食,腰还那么细!

jmton 发表于 2013-5-19 04:50:09

好好 学习了 确实不错
页: [1]
查看完整版本: 安装配置Cacti+Nginx+PHP+MYSQL