Chinaunix首页 | 论坛 | 博客
  • 博客访问: 706020
  • 博文数量: 112
  • 博客积分: 3889
  • 博客等级: 少校
  • 技术积分: 1448
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-19 16:35
个人简介

追求卓越,成功就会在不经意间追上你

文章分类

全部博文(112)

文章存档

2015年(1)

2014年(2)

2013年(1)

2012年(16)

2011年(86)

2010年(6)

分类: LINUX

2012-03-12 15:31:42

前几天分别写了mysql/apache/php自动安装脚本,但那仅限于单个安装;这两天寻思着整个脚本,根据实际需要调用之前的三个脚本,比如只要安装mysql就只调用install_mysql.脚本,如果要安装apache+php就分别调用install_apache.sh及install_php.sh脚本


本脚本在 centos5.7 x86_64下测试通过  lamp自动安装脚本包.zip   

 

下面是脚本的具体内容:

使用方法举例:bash install_lamp.sh mysql-5.5.19.tar.gz apache-5.3.7.tar.bz2

很简单的实现,热烈欢迎大家拍砖

 


点击(此处)折叠或打开

  1. #!/bin/bash
  2. #FileName:install_lamp.sh
  3. #Desc:invoke some scripts to intall mysql,apache,php
  4. #Created By:xiaozhenggang(fedoracle)
  5. #Date:2012/03/12
  6. #Version:1.0
  7.  
  8. if [ $UID -ne 0 ];then
  9.     echo -e "\033[31m This script must be execute by user root!"
  10.     exit 1
  11. fi
  12.  
  13. if [ $# -eq 1 ];then
  14.    PKG_VERSION=$1
  15.    PKG_NAME=`echo ${PKG_VERSION%%-*}`
  16.    case $PKG_NAME in
  17.    "mysql")
  18.       bash install_mysql.sh $PKG_VERSION
  19.    ;;
  20.    "httpd")
  21.       bash install_apache.sh $PKG_VERSION
  22.    ;;
  23.    "php")
  24.       bash install_php.sh $PKG_VERSION
  25.    ;;
  26.    *)
  27.       echo -e "\033[31m Package not matched!\nPlease enter full name of the package \nwhich you'll install such as :mysql-5.5.19.tar.gz \033[0m"
  28.       exit 4
  29.    ;;
  30.    esac
  31.  
  32. elif [ $# -eq 2 ];then
  33.    for PACKAGE in $1 $2
  34.    do
  35.       PKG_VERSION=$PACKAGE
  36.       PKG_NAME=`echo ${PACKAGE%%-*}`
  37.       case $PKG_NAME in
  38.          "httpd")
  39.             bash install_apache.sh $PKG_VERSION
  40.          ;;
  41.          "php")
  42.             bash install_php.sh $PKG_VERSION
  43.          ;;
  44.          *)
  45.             echo -e "\033[31m Package not matched!\nPlease enter full name for the package \nwhich you'll install such as:httpd-2.2.21.tar.gz \033[0m"
  46.             exit 3
  47.       esac
  48.    done
  49.  
  50. elif [ $# -eq 3 ];then
  51.    for PACKAGE in $1 $2 $3
  52.    do
  53.       PKG_VERSION=$PACKAGE
  54.       PKG_NAME=`echo ${PACKAGE%%-*}`
  55.  
  56.       case $PKG_NAME in
  57.          "mysql")
  58.             bash install_mysql.sh $PKG_VERSION
  59.          ;;
  60.          "httpd")
  61.             bash install_apache.sh $PKG_VERSION
  62.          ;;
  63.          "php")
  64.             bash install_php.sh $PKG_VERSION
  65.          ;;
  66.          *)
  67.             echo -e "\033[31m Package not matched!\nPlease enter full name for the package \nwhich you'll install such as:php-5.3.7.tar.gz \033[0m"
  68.             exit 2
  69.          ;;
  70.       esac
  71.    done
  72. else
  73.    echo -e "\033[31m Parameters enter error!Please make sure you have entired correctly!!! \033[0m"
  74.    exit 1
  75. fi


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