Chinaunix首页 | 论坛 | 博客
  • 博客访问: 11126
  • 博文数量: 5
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 50
  • 用 户 组: 普通用户
  • 注册时间: 2016-01-07 14:37
个人简介

个人是个linux菜鸟 希望大家多多交流吧

文章分类
文章存档

2016年(5)

我的朋友
最近访客

分类: 系统运维

2016-06-21 16:53:29


点击(此处)折叠或打开

  1. #!/bin/bash
  2. #by authores lihc 2016

  3. #Http define path variable

  4. H_FILES=httpd-2.2.24.tar.gz
  5. H_FILES_DIR=httpd-2.2.24
  6. H_PREFIX=/usr/local/apache
  7. H_TAR=/root/shell

  8. #Mysql define path variable
  9. M_FILES=mysql-5.6.16.tar.gz
  10. M_FILES_DIR=mysql-5.6.16
  11. M_PREFIX=/usr/local/mysql
  12. M_TAR=/root/shell

  13. #Php define path variable
  14. P_FILES=php-5.3.27.tar.gz
  15. P_FILES_DIR=php-5.3.27
  16. P_PREFIX=/usr/local/php
  17. P_TAR=/root/shell


  18. if [ -z "$1" ];then

  19.     echo -e "\033[32m1)安装httpd服务\033[0m"
  20.     echo -e "\033[32m2)安装mysql服务\033[0m"
  21.     echo -e "\033[32m3)安装php服务\033[0m"
  22.     echo -e "\033[32m4)配置http服务并启动\033[0m"
  23.     echo -e "\033[32mUsage: please input{1|2|3|4|help}"
  24. fi
  25. #Install httpd server
  26. if [[ "$1" -eq "1" ]];then
  27.     tar -zvxf $H_TAR/$H_FILES && cd $H_TAR/$H_FILES_DIR &&./configure --prefix=$H_PREFIX
  28.     if [ $? -eq 0 ];then
  29.         make && make install
  30.         echo -e "\033[32mThe httpd server is install success!\033[0m"
  31.     else
  32.         echo -e "\033[32mThe httpd server is install failed Please check..\033[0m"
  33.         exit
  34.     fi
  35. fi

  36. #Install mysql server

  37. if [[ "$1" -eq "2" ]];then
  38.         tar -zvxf $M_TAR/$M_FILES && cd $M_TAR/$M_FILES_DIR && cmake \
  39.     -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
  40.     -DMYSQL_DATADIR=/usr/local/mysql/data \
  41.     -DSYSCONFDIR=/etc \
  42.     -DWITH_MYISAM_STORAGE_ENGINE=1 \
  43.     -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  44.     -DWITH_MEMORY_STORAGE_ENGINE=1 \
  45.     -DWITH_READLINE=1 \
  46.     -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
  47.     -DMYSQL_TCP_PORT=3306 \
  48.     -DENABLED_LOCAL_INFILE=1 \
  49.     -DWITH_PARTITION_STORAGE_ENGINE=1 \
  50.     -DEXTRA_CHARSETS=all \
  51.     -DDEFAULT_CHARSET=utf8 \
  52.     -DDEFAULT_COLLATION=utf8_general_ci
  53.         if [ $? -eq 0 ];then
  54.                 make && make install
  55.         chown -R mysql:mysql $M_PREFIX
  56.         cd $M_PREFIX
  57.         scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
  58.         cp support-files/mysql.server /etc/init.d/mysql
  59.         cp support-files/my-default.cnf /etc/my.cnf
  60.         chkconfig --add mysql
  61.         chkconfig mysql on
  62.                 echo -e "\033[32mThe mysql server is install success!\033[0m"
  63.         else
  64.                 echo -e "\033[32mThe mysql server is install failed Please check..\033[0m"
  65.                 exit
  66.         fi
  67. fi


  68. #Install php server
  69.     
  70. if [[ "$1" -eq "3" ]];then
  71.         tar -zvxf $P_TAR/$P_FILES && cd $P_TAR/$P_FILES_DIR &&./configure --prefix=$P_PREFIX --with-mysql=$M_PREFIX --with-apxs2=$H_PREFIX/bin/apxs

  72.         if [ $? -eq 0 ];then
  73.                 make && make install
  74.                 echo -e "\033[32mThe php server is install success!\033[0m"
  75.         else
  76.                 echo -e "\033[32mThe php server is install failed Please check..\033[0m"
  77.                 exit
  78.         fi
  79. fi

  80. if [[ "$1" -eq "4" ]];then
  81.     sed -i '/DirectoryIndex/s/index.html/index.php index.html/g' $H_PREFIX/conf/httpd.conf
  82.     echo "Addtype    application/x-httpd-php .php">>$H_PREFIX/conf/httpd.conf
  83.     $H_PREFIX/bin/apachectl start
  84.     IP=`ifconfig |awk NR==2'{print $2}'|awk -F: '{print $2}'`
  85.     echo -e "\033[32mYou can access \033[0m"
  86. cat >$H_PREFIX/htdocs/index.php <<EOF
  87. <?php
  88. phpinfo();
  89. ?>
  90. EOF
  91. fi


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