热门IT资讯网

一起搭建linux监控平台之nagios(一)lamp环境

发表于:2024-11-26 作者:热门IT资讯网编辑
编辑最后更新 2024年11月26日,环境OS:centos 5.8 x86_64这次脚本比上篇有些许修改,脚本如下#mkdir /etc/yum.repos.d/backup#mv /etc/yum.repos.d/*.repo /et

环境OS:centos 5.8 x86_64

这次脚本比上篇有些许修改,脚本如下

  1. #mkdir /etc/yum.repos.d/backup
  2. #mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/
  3. #mv /tmp/lamp/ftp.repo /etc/yum.repos.d/
  4. #yum clean all
  5. #yum makecache
  6. path=`pwd`
  7. yum -y install gcc gcc-c++ screen autoconf automake libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel pcre pcre-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libtiff libtiff-devel gettext gettext-devel pam pam-devel fontconfig-devel libXpm-devel libtool php-common
  8. cd $path
  9. tar -zxvf httpd-2.2.9.tar.gz
  10. cd $path/httpd-2.2.9
  11. ./configure --prefix=/usr/local/apache2/ --sysconfdir=/etc/httpd/ --with-included-apr --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support
  12. make
  13. make install
  14. mv $path/httpd /etc/rc.d/init.d/httpd
  15. chmod +x /etc/rc.d/init.d/httpd
  16. chkconfig --add httpd
  17. chkconfig httpd on
  18. service httpd start
  19. #install mysql-server
  20. groupadd mysql
  21. useradd -g mysql mysql
  22. mkdir -p /data/mysql/var
  23. cd $path
  24. tar -zxvf Percona-Server-5.1.58.tar.gz
  25. cd $path/Percona-Server-5.1.58
  26. ./configure --prefix=/usr/local/mysql/ --localstatedir=/data/mysql/var --with-extra-charsets=utf8,gbk --with-pthread --enable-thread-safe-client --with-ssl --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-plugins=partition,innobase,csv,myisam,innodb_plugin --enable-shared --enable-assembler
  27. make && make install
  28. cp support-files/my-medium.cnf /etc/my.cnf
  29. cp support-files/mysql.server /etc/init.d/mysqld
  30. chmod +x /etc/init.d/mysqld
  31. ln -s /usr/local/mysql/bin/* /usr/local/bin/
  32. ln -s /usr/local/mysql/lib/mysql/lib* /usr/lib/
  33. /usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql/var --user=mysql &
  34. chown -R root.mysql /usr/local/mysql/
  35. #chown -R mysql.mysql /usr/local/mysql/var/
  36. chown -R mysql.mysql /data/mysql/
  37. sed -i '38a\basedir = /usr/local/mysql/ \' /etc/my.cnf
  38. sed -i '39a\datadir = /data/mysql/var/ \' /etc/my.cnf
  39. service mysqld start
  40. #install php
  41. cd $path
  42. tar -zxvf libmcrypt-2.5.8.tar.gz
  43. cd $path/libmcrypt-2.5.8/
  44. ./configure --prefix=/usr/local/libmcrypt/
  45. make
  46. make install
  47. cd $path/libmcrypt-2.5.8/libltdl
  48. ./configure --enable-ltdl-install
  49. make
  50. make install
  51. cd $path
  52. tar -zxvf libiconv-1.13.1.tar.gz
  53. cd $path/libiconv-1.13.1
  54. ./configure --prefix=/usr/local/
  55. make
  56. make install
  57. ln -s /usr/local/lib/libmcrypt* /usr/lib
  58. ln -s /usr/local/lib/libiconv.* /usr/lib
  59. ln -s /usr/local/lib/libiconv.* /usr/lib64/
  60. yum -y install libxml2-devel curl-devel libpng-devel openldap-devel
  61. cd $path
  62. tar -zxvf php-5.2.6.tar.gz
  63. cd $path/php-5.2.6
  64. ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-iconv-dir=/usr/local --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-gd --with-zlib-dir --with-mcrypt=/usr/local/libmcrypt --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets
  65. make ZEND_EXTRA_LIBS='-liconv'
  66. make install
  67. ln -s /usr/local/php/bin/php /usr/bin/
  68. cp php.ini-dist /usr/local/php/etc/php.ini
  69. sed -i '170 s/DirectoryIndex/ DirectoryIndex index.php/' /etc/httpd/httpd.conf
  70. sed -i '312a\ AddType application/x-httpd-php .php .phtml \' /etc/httpd/httpd.conf
  71. cd $path
  72. tar -zxvf PDO_MYSQL-1.0.2.tgz
  73. cd PDO_MYSQL-1.0.2
  74. /usr/local/php/bin/phpize
  75. ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
  76. make && make install
  77. sed -i '486 s/extension_dir/ ;extension_dir/' /usr/local/php/etc/php.ini
  78. sed -i '597a extension = "pdo_mysql.so" ' /usr/local/php/etc/php.ini
  79. sed -i 's#;date.timezone.*#date.timezone = "Shanghai/Asia"# '/usr/local/php/etc/php.ini
  80. cp $path/index.php /usr/local/apache2/htdocs/index.php
  81. #/usr/local/apache2/bin/apachectl restart
  82. service httpd restart
  83. service mysqld restart

想单独下载lamp安装包,地址如下:

http://down.51cto.com/data/596769 免豆下载

补充一下:yum源请事先先设置好,直接解压完,执行./install-all.sh就可以了

apache安装目录:/usr/local/apache2

php:/usr/local/php

mysql:/usr/lcoal/mysql

0