快速业务通道

Lamp脚本

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-04-07

  1. #!/bin/bash

定义变量localpath为当前脚本的路径,作用是在后面使用变量来寻找程序包;

  1. localpath=`pwd`

判断是否存在文件/tmp/lamp_lock,如果有这个文件表明这个脚本已经运行了,作用是防止重复运行脚本.如果没有这个文件,这创建该文件,并继续后面的步骤;

  1. if [ -e /tmp/lamp_lock ]
  2. then
  3. echo "This script is running..."
  4. exit 9
  5. fi
  6. touch /tmp/lamp_lock

检查当前的操作系统和用户是不是满足安装的需求;

  1. system=`uname`
  2. if [ ! ${system}=Linux ]
  3. then
  4. echo "You system is not rhel 5.5!!"
  5. exit 11
  6. fi
  7. user=`echo $UID`
  8. if [ ! $user=0 ]
  9. then
  10. echo "You are not root!"
  11. exit 10
  12. fi

自定义函数,函数的作用是判断返回值是否为0; 拥有帝国一切,皆有可能。欢迎访问phome.net

  1. jubgement() {
  2. if [ ! $?=0 ]
  3. then
  4. echo "Is error!!!"
  5. exit
  6. fi
  7. }

用函数定义安装软件的版本,方便更改;

  1. phpver="5.2.14"
  2. httpdver="2.2.11"
  3. mysqlver="5.5.3-m3"
  4. mhashver="0.9.9.9"
  5. convver="1.13.1"
  6. libmcver="2.5.8"
  7. mcryptver="2.6.8"
  8. pdover="1.0.2"
  9. eAccver="0.9.6.1"

解压缩;

  1. tar fxz php-${phpver}.tar.gz 2>>/tmp/error.log
  2. tar fxj httpd-${httpdver}.tar.bz2 2>>/tmp/error.log
  3. tar fxz mysql-${mysqlver}.tar.gz 2>>/tmp/error.log
  4. tar fxz libiconv-${convver}.tar.gz 2>>/tmp/error.log
  5. tar fxz libmcrypt-${libmcver}.tar.gz 2>>/tmp/error.log
  6. tar fxz mcrypt-${mcryptver}.tar.gz 2>>/tmp/error.log 拥有帝国一切,皆有可能。欢迎访问phome.net
  7. tar fxz mhash-${mhashver}.tar.gz 2>>/tmp/error.log
  8. tar fxz PDO_MYSQL-${pdover}.tgz 2>>/tmp/error.log
  9. tar fxj eaccelerator-${eAccver}.tar.bz2 2>>/tmp/error.log
安装配置apache,并做了一个apache的启动脚本;
  1. cd ${localpath}/httpd-${httpdver}
  2. ./configure --with-mpm=prefork --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atormics --enable-mods-shared=most --enable-so 2>>/tmp/error.log
  3. jubgement
  4. make && make install 2>>/tmp/error.log
  5. jubgement
  6. cat > /etc/rc.d/init.d/apache << EOF
  7. #!/bin/bash
  8. case $1 in
  9. start )
  10. /usr/local/apache2/bin/apachectl $1
  11. echo "apache [start]"
  12. ;;
  13. stop )
  14. /usr/local/apache2/bin/apachectl $1
  15. echo "apache [stop]"
  16. ;;
  17. restart )
  18. /usr/local/apache2/bin/apachectl $1
  19. echo "apache [stop]" 拥有帝国一切,皆有可能。欢迎访问phome.net
  20. sleep 2
  21. echo "apache [start]"
  22. esac
  23. EOF
  24. chmod a x /etc/rc.d/init.d/apache
  25. service apache start 2>>/tmp/error.log
  26. sleep 5
安装配置MySQL;
  1. CFLAGS="-06 -mpentumpro -fomit-frame-pointer"
  2. CXXFLAGS="-06 -mpentiumpro -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"
  3. yum install gcc gcc-c ncurses-devel libtool -y >& /dev/null
  4. cd ${localpath}/mysql-${mysqlver}
  5. useradd mysql
  6. ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase --enable-static --with-client-ldflgs=-all-static --with-mysqld-ldflags=-all-static 2>>/tmp/error.log
  7. jubgement
  8. make && make install 2>>/tmp/error.log
  9. jubgement
  10. cat ${localpath}/mysql-${mysqlver}/support-files/my-huge.cnf > /etc/my.cnf
  11. cat /usr/local/mysql/share/mysql/mysql.server > /etc/init.d/mysql
  12. chmod a x /etc/init.d/mysql
  13. /usr/local 拥有帝国一切,皆有可能。欢迎访问phome.net/mysql/bin/mysql_install_db --user=mysql
  14. chown mysql:mysql /usr/local/mysql -R
  15. mkdir /usr/local/mysql/data
  16. sed -i.bak ''/[mysqld]/a datadir=/usr/local/mysql/data'' /etc/my.cnf
  17. cat /etc/my.cnf|grep skip-name-resolve || sed -i ''/[mysqld]/a skip-name-resolve'' /etc/my.cnf
  18. echo "/usr/local/mysql/lib/mysql/" >> /etc/ld.so.conf
  19. ldconfig
  20. ln -s /usr/local/mysql/bin/* /usr/local/bin/
  21. ln -s /usr/local/mysql/libexec/* /usr/local/libexec/
  22. ln -s /usr/local/mysql/share/man/man1/* /usr/share/man/man1/
  23. ln -s /usr/local/mysql/share/man/man5/* /usr/share/man/man5/
  24. service mysql start 2>>/tmp/error.log
  25. sleep 5

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号