Chinaunix首页 | 论坛 | 博客
  • 博客访问: 283381
  • 博文数量: 44
  • 博客积分: 2046
  • 博客等级: 大尉
  • 技术积分: 611
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-06 11:11
文章分类

全部博文(44)

文章存档

2011年(1)

2010年(43)

我的朋友

分类:

2010-07-27 16:19:47

#!/bin/bash
####一、系统环境部署及调整####
####1、检查系统是否正常,检查有无系统级错误信息
tail -n100 /var/log/messages
####2、检查硬件设备是否有错误信息
dmesg
####3、检查网卡设置是否正确
ifconfig
####4、检查网络是否正常
ping

####2、检查及更新系统GCC C++等语言环境####
yum -y install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel \
ncurses-devel openssl-devel libtool* zlib-devel libxml2-devel libjpeg-devel libpng-devel
libtiff-devel \
fontconfig-devel freetype-devel libXpm-devel gettext-devel curl curl-devel pam-devel \
e2fsprogs-devel krb5-devel libidn libidn-devel

####3、定时校正服务器时钟,与时钟服务器进行时间同步####
ntpdate time.nist.gov
####添加每天定时进行时钟同步####
crontab -e
####添加以下内容####
15 3 * * * /usr/sbin/ntpdate time.nist.gov > /dev/null 2>&1

####二、LAMP安装及配置####
####1、安装ncurses-5.6(ncurses是一种能提供基于文本终端窗口功能的动态库)####
cd /root/soft/lamp/
tar -zxvf  ncurses-5.6.tar.gz
cd /root/soft/lamp/ncurses-5.6
./configure --prefix=/usr --with-shared --without-debug
make
make install
####2、MYSQL安装与配置(mysql一种开源的数据库)####
####Mysql安装####
groupadd mysql
useradd mysql -d /dev/null -g mysql -s /sbin/nologin
cd /root/soft/lamp/
tar -zxvf mysql-5.1.30.tar.gz
cd /root/soft/lamp/mysql-5.1.30
./configure --with-mysqld-user=mysql --prefix=/usr/local/mysql5 --with-charset=gbk --with-extra
-charset=all --without-isam --exec-prefix=/usr/local/mysql5
make
make install
####Mysql配置####
/usr/local/mysql5/bin/mysql_install_db       
chown -R mysql.mysql /usr/local/mysql5/
cp /usr/local/mysql5/share/mysql/my-medium.cnf /etc/my.cnf 
cp support-files/mysql.server /etc/rc.d/init.d/mysqld     
chmod 700 /etc/rc.d/init.d/mysqld                        
/usr/local/mysql5/bin/mysqld_safe --user=mysql &         
/etc/rc.d/init.d/mysqld start
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
ln -s /usr/local/mysql5/bin/mysql /sbin/mysql
ln -s /usr/local/mysql5/bin/mysqladmin /sbin/mysqladmin
#####配置库文件搜索路径
echo "/usr/local/mysql5/lib/mysql" >> /etc/ld.so.conf
#####添加/usr/local/mysql5/bin到环境变量PATH中
export PATH=$PATH:/usr/local/mysql5/bin
####3、安装zlib(安装lamp的必备源码)####
cd /root/soft/lamp/
tar jxvf zlib-1.2.3.tar.bz2
cd /root/soft/lamp/zlib-1.2.3
./configure
make
make install

####4、安装openssl-0.9.8g(通信加密组件)####
cd /root/soft/lamp/
tar zxvf openssl-0.9.8g.tar.gz
cd /root/soft/lamp/openssl-0.9.8g
./config shared zlib
make
make test
make install
mv /usr/bin/openssl /usr/bin/openssl.OFF
mv /usr/include/openssl /usr/include/openssl.OFF
rm /usr/lib/libssl.so
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
ln -sv /usr/local/ssl/lib/libssl.so.0.9.8 /usr/lib/libssl.so
#配置库文件搜索路径
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf

####5、安装BerkeleyDB(高性能的,嵌入数据库编程库)####
cd /root/soft/lamp/
tar zxvf db-4.4.20.tar.gz
cd /root/soft/lamp/db-4.4.20/build_unix
../dist/configure --prefix=/usr/local/BerkeleyDB
make && make install
ln -sv /usr/local/BerkeleyDB/include /usr/include/db4
ln -sv /usr/local/BerkeleyDB/include/db.h /usr/include/db.h
ln -sv /usr/local/BerkeleyDB/include/db_cxx.h /usr/include/db_cxx.h
echo "/usr/local/BerkeleyDB/lib" >> /etc/ld.so.conf
ldconfig

####6、安装httpd-2.2.8(WEB服务器)####
cd /root/soft/lamp/
tar jxvf httpd-2.2.13.tar.bz2
cd /root/soft/lamp/httpd-2.2.13
./configure --prefix=/usr/local/apache2 --enable-module=rewrite --enable-module=so --enable-so
--enable-ssl --with-ssl=/usr/local/ssl --enable-track-vars --enable-rewrite --with-zlib --
enable-mods-shared=most --enable-suexec --with-suexec-caller=daemon
make && make install
 
echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.d/rc.local
/usr/local/apache2/bin/apachectl start
####注:在这一步时极有可能会出现下列报错,这个报错是因为本系统开启了selinux功能,我们可以进行下
列操作,关闭该功能,再启动时就没有问题:
####httpd: Syntax error on line 75 of /httpd/apache/conf/httpd.conf: Cannot load
/httpd/apache/modules/mod_deflate.so into server:/httpd/apache/modules/mod_deflate.so: cannot
restore segment prot after reloc:Permission denied
vi /etc/selinux/config
找到SELINUX=“XXXXX”项把后面的参数修改为“disable”

####7、安装libPNG(是多种应用程序使用的解析PNG图象格式的库)####
cd /root/soft/lamp/
tar zxvf  libpng-1.2.14.tar.gz
cd /root/soft/lamp/libpng-1.2.14
cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng
make && make install
####8、安装freetype(高度模块化的字体程序库)####
cd /root/soft/lamp/
tar jxvf freetype-2.3.5.tar.bz2
cd /root/soft/lamp/freetype-2.3.5
./configure
make && make install
####9、安装JPEG6####
cd /root/soft/lamp/
tar zxvf jpegsrc.v6b.tar.gz
cd /root/soft/lamp/jpeg-6b
mkdir -pv /usr/local/jpeg/{,bin,lib,include,man/man1,man1}
./configure --prefix=/usr/local/jpeg --enable-shared --enable- static
make && make install
####10、安装GD####
cd /root/soft/lamp/
tar zxvf gd-2.0.35.tar.gz
cd /root/soft/lamp/gd-2.0.35
./configure --with-png --with-freetype --with-jpeg=/usr/local/jpeg/
make && make install
####11、安装LIBXML2####
cd /root/soft/lamp/
tar zxvf libxml2-2.6.31.tar.gz
cd /root/soft/lamp/libxml2-2.6.31
./configure --prefix=/usr/local/libxml2
make && make install
cp xml2-config /usr/bin
####12、安装libmcrypt####
cd /root/soft/lamp/
tar zxvf libmcrypt-2.5.7.tar.gz
cd /root/soft/lamp/libmcrypt-2.5.7
./configure
make && make install
####13、安装PHP5.2.5####
cd /root/soft/lamp/
tar jxvf php-5.2.5.tar.bz2
cd /root/soft/lamp/php-5.2.5
./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql5 --with-
apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg --with-freetype-
dir=/usr/local/include/freetype2 --with-zlib --with-png-dir=usr/local/libpng12 --with-libxml-
dir=/usr/local/libxml2 --with-gd --enable-ftp --enable-sockets -enable-mbstring=all- --with-
mcrypt --with-mysqli=/usr/local/mysql5/bin/mysql_config
make && make install
####配置apache与php####
cp /root/soft/lamp/php-5.2.5/php.ini-dist /usr/local/apache2/conf/php.ini
vi /usr/local/apache2/conf/php.ini
####查找default_charset = "iso-8859-1",在这行下方添加:####
default_charset = "gbk"
vi /usr/local/apache2/conf/httpd.conf
####查找AddType application/x-gzip .tgz,在这行下方添加:####
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
####查找IfModule dir_module,在index.html前面添加:####
index.php,
####重启httpd服务####
vi /usr/local/apache2/htdocs/index.php
phpinfo();
?>
####打开IE浏览器,测试PHP功能是否正常####
####14、安装ZendOptimizer####
cd /root/soft/lamp/
tar -zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
cd /root/soft/lamp/ZendOptimizer-3.3.3-linux-glibc23-i386
./install
####安装在图形下进行,安装时注意根据提示选择就可以####
echo "LINUX+MYSQL+APACHE2+PHP5+ZEND INSTALL OK"
####15、安装Time::HiRes####
cd /root/soft/lamp/
tar zxvf Time-HiRes-1.9715.tar.gz
cd /root/soft/lamp/Time-HiRes-1.9715
perl Makefile.PL
make
make test
make install
####16、安装File::Tail####
cd /root/soft/lamp/
tar zxvf File-Tail-0.99.3.tar.gz
cd /root/soft/lamp/File-Tail-0.99.3
perl Makefile.PL
make
make test
make install
####17、安装libart_lgpl-devel####
cd /root/soft/lamp/
rpm -ivh libart_lgpl-devel-2.3.17-4.i386.rpm
####18、安装cgilib####
cd /root/soft/lamp/
tar zxvf cgilib-0.5.tar.gz
cd /root/soft/lamp/cgilib-0.5
make
cp libcgi.a /usr/local/lib
cp cgi.h /usr/include
ln -s /usr/local/include/freetype2/ /usr/include/freetype2
####19、安装rrdtool-1.2.23####
cd /root/soft/lamp/
tar zxvf rrdtool-1.2.29.tar.gz
cd /root/soft/lamp/rrdtool-1.2.29
./configure --prefix=/usr/local/rrdtool
make
make install
####20、安装net-snmp####
cd /root/soft/lamp/
tar -zxvf net-snmp-5.3.2.tar.gz
cd /root/soft/lamp/net-snmp-5.3.2
./configure --prefix=/usr/local/snmp --enable-developer
make && make install
ln –s /usr/local/snmp/bin/* /usr/local/bin/
cp EXAMPLE.conf /usr/local/snmp/share/snmp/snmpd.conf
#vi /usr/local/snmp/share/snmp/snmpd.conf
#com2sec local localhost public
#com2sec mynetwork 192.168.8.0/24 public

/usr/local/snmp/sbin/snmpd -c /usr/local/snmp/share/snmp/snmpd.conf
echo "/usr/local/snmp/sbin/snmpd -c /usr/local/snmp/share/snmp/snmpd.conf" >> /etc/rc.local
PATH=/usr/local/snmp/bin/:/usr/local/snmp/sbin/:$PATH
cd ../
####21、安装cacti####
cd /root/soft/lamp/
useradd cactiuser -g users
passwd cactiuser (pwd:cactipw)
tar -zxvf cacti-0.8.7b.tar.gz
mkdir -p /data/www/
mv cacti-0.8.7b /data/www/cacti
#创建cactidb数据库
/usr/local/mysql5/bin/mysqladmin -u root password nginx
/usr/local/mysql5/bin/mysql -u root -pnginx
create database cactidb;
grant all on cactidb.* to identified by 'cactipw';
exit;
cd /data/www/cacti
/usr/local/mysql5/bin/mysql -u root -pnginx cactidb chown -R cactiuser rra/ log/
cd scripts
chown cactiuser:users *
vi /data/www/cacti/include/config.php
$database_type = “mysql”;
$database_default = “cactidb”;
$database_hostname = “localhost”;
$database_username = “cactiuser”;
$database_password = “cactipw”;
$database_port = "3306";
vi /data/www/cacti/include/global.php
$database_type = "mysql";
$database_default = "monitor";
$database_hostname = "localhost";
$database_username = "monitor";
$database_password ="monitor123";
$database_port = "3306";
$plugins = array();
//$plugins[] = 'thold';
$config = array();
crontab -u cactiuser -e
加入
*/5 * * * * /usr/local/php5/bin/php /data/www/cacti/poller.php > /dev/null 2>&1
 # admin   admin     cactipw
su cactiuser
/usr/local/php5/bin/php /data/www/cacti/poller.php
# 把cacti目录里的cmd.php和poller.php文件加下运行的权限
#测试SNMP是不是工作正常 snmpwalk -c community -v 2c hostIP if正常的话会出现一些数据。不正常会出
现一些错误,也会有对应的错误提示。
#我原来使用的是rrdtool-1.0.x 升级到 1.2.x 后部分图像无法显示(Zoom)
#修改Configuration -> Settings -> RRDTool Utility Version -> 1.2.x
#/usr/local/rrdtool/bin/rrdtool fetch /data/www/cacti/rra/localhost_mem_swap_4.rrd AVERAGE
#查看是否获取数据
 

 
阅读(787) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~