apache+php+mysql+nagios+cacti
我是在完全干净的Ubuntu10.04下源码编译安装的,如有些地方不妥,还请指出。由于本人运气不太好,安装配置过程中把网上出现的问题都遇见了,顾也写出FAQ解决方法。
Begin 安装前保证一些开发包如gcc,g++已经装上。
1. 安装apache2.2.19
tar zxvf httpd-2.2.19.tar.gz
cd httpd-2.2.19
./configure --prefix=/usr/local/apache --enable-so
#记得enable-so,不然后面会出问题
make
make install
vim /usr/local/apache/conf/httpd.conf
设置 ServerName 为 0.0.0.0:80
ln -s /usr/local/apache/bin/apachectl /etc/init.d/httpd #启动项
/usr/local/apache/bin/apachectl start
打开浏览器,输入http://0.0.0.0:80 会出现It's works #查看apache是否安装正确
2. 安装mysql-5.5.14
如果没有安装cmake,首先安装cmake才能编译。
tar -zxvf cmake-2.8.5.tar.gz
cd cmake-2.8.5
./bootstrap;make;make install
安装完后,安装mysql
tar zxvf mysql-5.5.14.tar.gz
cd mysql-5.5.14
groupadd mysql
useradd -r -g mysql mysql
/usr/local/bin/cmake . #cmake当前文件,注意有个点“.”
安装过程中可能会报以下错误
Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
发现少库, Ubuntu下要安装libncurses5-dev
apt-get install libncurses5-dev
不知道库名可以用aptitude-search 来搜索
删除mysql文件夹,重新解压,tar zxvf mysql-5.5.14.tar.gz
cd mysql-5.5.14
重新 执行 /usr/local/bin/cmake .
make
make install
安装 /usr/local/gd
tar zxvf gd-2.0.35.tar.gz
cd gd/2.0.35/
./configure --prefix=/usr/local/gd
make
make install
tar xvf php-5.3.6.tar.bz2
cd php-5.3.6
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-gd=/usr/local/gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --enable-gd-native-ttf --enable-gd-jis-conv --enable-xml --enable-mbstring --enable-sockets --enable-bcmath
#--enable-bcmath 是以后装zabbix需要的。
make
make install
vim /usr/local/apache/conf/httpd.conf
在合适位置加上 LoadModule php5_module modules/libphp5.so
4.安装rrdtool
Rrdtool需要一些库文件的支持,这些库文件的安装非常耽误时间,在此我们使用
apt-get install 相关库文件来装,装得不全会报错的。一定要装完
cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel intltool
不然就会 configure: error: Please fix the library issues listed above and try again.
tar -zxvf rrdtool-1.4.5.tar.gz
cd rrdtoos-1.4.5
./configure --prefix=/usr/local/rrdtool --disable-tcl
make
make install
ln -s /usr/local/rrdtool/bin/* /usr/local/bin/
cp -r gbsn00lp.ttf /usr/share/fonts/zh_CN/TrueType/ 复制字体给rrdtool 使用
5.安装net-snamp
tar zxvf net-snmp-5.4.2.1.tar.gz
cd net-snmp-5.4.2.1
./configure --prefix=/usr/local/net-snmp --enable-developer
make
如果报错
/usr/bin/ld: cannot find -lperl
collect2: ld returned 1 exit status
vim /usr/local/neit-snmp/share/snmp/snmpd.conf修改可以访问SNMP的网段和community
比如
# sec.name source community
com2sec local localhost public
com2sec mynetwork 192.168.15.1 public
com2sec mynetwork 192.168.1.1 public
编译并安装 Nagios 插件
tar -zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
vim /usr/local/apache/conf/httpd.conf
添加以下到最后
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
# Last Modified: 11-26-2005
#
# This file contains examples of entries that need
# to be incorporated into your Apache web server
# configuration file. Customize the paths, etc. as
# needed to fit your system.
2.It seems that you have chosen to not use the authentication functionality of the CGIs.
I don't want to be personally responsible for what may happen as a result of allowing unauthorized users to issue commands to Nagios,so you'll have to disable this safeguard if you are really stubborn and want to invite trouble.
如果不是 nagiosadmin 需要到后面添加
例子 authorized_for_system_information=nagiosadmin,admin
3.Ubuntu下安装MySQL出现FATAL ERROR: Could not find mysqld的处理
错误信息:
#./bin/mysql_install_db –user=mysql
FATAL ERROR: Could not find mysqld
The following directories were searched:
/usr/libexec
/usr/sbin
/usr/bin
If you compiled from source, you need to run ‘make install’to copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top of the level of the extracted archivem or pass the –basedir option pointing to that location.
解决办法:
在安装目录下运行 scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
(这里mysql是所使用的用户名,basedir是mysql的安装目录)
4.安装cacti时,在导入cacti.sql 这个文件时报错:
The command "mysql -u root -p cacti < cacti.sql' gets the following error:
ERROR 1064 (42000) at line 5: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 6
原因是mysql5这后不再支持 TYPE=MyISAM 这样的语法了,改成 ENGINE=MyISAM 就可以了。
5.Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/apache2/htdocs/include/global_constants.php on line 154