Chinaunix首页 | 论坛 | 博客
  • 博客访问: 401965
  • 博文数量: 112
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 800
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-29 13:41
文章分类

全部博文(112)

文章存档

2020年(1)

2018年(10)

2017年(27)

2016年(18)

2015年(31)

2014年(25)

分类: 系统运维

2018-12-05 06:53:37


点击(此处)折叠或打开

  1. #!/bin/bash
  2. #
  3. APP_PKG=(
  4.     httpd-2.4.37.tar.gz
  5.     apr-1.6.5.tar.gz
  6.     apr-util-1.6.1.tar.gz
  7.     mysql-5.5.32.tar.gz
  8.     cmake-2.8.8.tar.gz
  9.     php-5.6.38.tar.gz
  10.     ComsenzDiscuz-DiscuzX-master.zip
  11. )
  12. LAMP_TMP=/tmp/lamp
  13. PRE_DIR=/usr/local
  14. #
  15. if [[ $UID -eq 0 ]];then
  16.     iptables -F
  17.     chkconfig iptables off
  18.     yum install apr-devel apr-util-devel pcre pcre-devel \
  19.     ncurses-devel libxml2 libxml2-devel -y
  20. else
  21.     echo "please use root install"
  22.     exit
  23. fi    

  24. httpd_install ()
  25. {
  26.     cd ${LAMP_TMP}
  27.     tar -zxf ${APP_PKG[0]}
  28.     tar -zxf ${APP_PKG[1]}
  29.     tar -zxf ${APP_PKG[2]}
  30.     cp -r ${APP_PKG[1]%.tar*} ${LAMP_TMP}/${APP_PKG[0]%.tar*}/srclib/${APP_PKG[1]%-*}
  31.     cp -r ${APP_PKG[2]%.tar*} ${LAMP_TMP}/${APP_PKG[0]%.tar*}/srclib/${APP_PKG[2]%-*}
  32.     cd ${APP_PKG[0]%.tar*}
  33.     ./configure --prefix=${PRE_DIR}/apache2 \
  34.                 --with-included-apr \
  35.                 --enable-rewrite --enable-so
  36.     make
  37.     make install
  38.     
  39. }

  40. mysql_install ()
  41. {
  42.     cd ${LAMP_TMP}
  43.     tar -zxf ${APP_PKG[4]}
  44.     cd ${APP_PKG[4]%.tar*}
  45.     sleep 2
  46.     ./configure
  47.     sleep 2
  48.     gmake
  49.     sleep 2
  50.     gmake install
  51.     groupadd mysql
  52.     useradd mysql -s /sbin/nologin -M -g mysql
  53.     cd ${LAMP_TMP}
  54.     tar -zxf ${APP_PKG[3]}
  55.     cd ${APP_PKG[3]%.tar*}
  56.     sleep 2
  57.     cmake . -DCMAKE_INSTALL_PREFIX=${PRE_DIR}/${APP_PKG[3]%.tar*} \
  58.     -DMYSQL_DATADIR=${PRE_DIR}/${APP_PKG[3]%.tar*}/data \
  59.     -DMYSQL_UNIX_ADDR=${PRE_DIR}/${APP_PKG[3]%.tar*}/tmp/mysql.sock \
  60.     -DDEFAULT_CHARSET=utf8 \
  61.     -DDEFAULT_COLLATION=utf8_general_ci \
  62.     -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
  63.     -DENABLED_LOCAL_INFILE=ON \
  64.     -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  65.     -DWITH_FEDERATED_STORAGE_ENGINE=1 \
  66.     -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
  67.     -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
  68.     -DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
  69.     -DWITH_FAST_MUTEXES=1 \
  70.     -DWITH_ZLIB=bundled \
  71.     -DENABLED_LOCAL_INFILE=1 \
  72.     -DWITH_READLINE=1 \
  73.     -DWITH_EMBEDDED_SERVER=1 \
  74.     -DWITH_DEBUG=0
  75.     
  76.     sleep 2
  77.     make
  78.     sleep 2
  79.     make install
  80.     ln -s ${PRE_DIR}/${APP_PKG[3]%.tar*} ${PRE_DIR}/${APP_PKG[3]%-*}
  81.     cp ${PRE_DIR}/${APP_PKG[3]%-*}/support-files/my-small.cnf /etc/my.cnf
  82.     echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile
  83.     source /etc/profile 2>&1
  84.     cd ${PRE_DIR}
  85.     chown -R mysql.mysql ${APP_PKG[3]%-*}/
  86.     chmod -R 1777 /tmp/
  87.     cd ${APP_PKG[3]%-*}/scripts/
  88.     ./mysql_install_db --basedir=${PRE_DIR}/${APP_PKG[3]%-*} --datadir=${PRE_DIR}/${APP_PKG[3]%-*}/data/ --user=mysql
  89.     cp ../support-files/mysql.server /etc/init.d/mysqld
  90.     chmod +x /etc/init.d/mysqld
  91.     /etc/init.d/mysqld start
  92.     chkconfig mysqld on
  93.     chkconfig --list mysqld
  94.     mysqladmin -uroot password '123456'
  95.     mysql -uroot -p123456 -e "drop database test;"
  96.     mysql -uroot -p123456 -e "delete from mysql.user where user='';"
  97.     mysql -uroot -p123456 -e "delete from mysql.user where host='hostname';"
  98.     mysql -uroot -p123456 -e "delete from mysql.user where host='::1';"
  99.    
  100. }

  101. php_install ()
  102. {
  103.     cd ${LAMP_TMP}
  104.     tar -zxf ${APP_PKG[5]}
  105.     cd ${APP_PKG[5]%.tar*}
  106.     ./configure --prefix=${PRE_DIR}/php5 \
  107.     --with-config-file-path=${PRE_DIR}/php/etc \
  108.     --with-apxs2=${PRE_DIR}/apache2/bin/apxs \
  109.     --with-mysql=${PRE_DIR}/${APP_PKG[3]%-*}
  110.     
  111.     make
  112.     make install
  113.     sed 's/#ServerName localhost/' -i ${PRE_DIR}/apache2/conf/httpd.conf
  114.     sed '/\/x-gzip \.gz/a AddType application/x-httpd-php .php' -i /usr/local/apache2/conf/httpd.conf
  115.     sed '/DirectoryIndex/s/index\.html/index.php &/' -i /usr/local/apache2/conf/httpd.conf
  116.     cat > ${PRE_DIR}/apache2/htdocs/index.php << EOF
  117. <?php
  118. phpinfo();
  119. ?>
  120. EOF
  121.     /usr/local/apache2/bin/apachectl restart
  122. }

  123. dis_install ()
  124. {
  125.     cd ${LAMP_TMP}
  126.     unzip ${APP_PKG[6]} -d ${PRE_DIR}/apache2/htdocs/
  127.     cd ${PRE_DIR}/apache2/htdocs/
  128.     mv `echo ${APP_PKG[6]}|awk -F"-" '{print $2}'`/upload/* .
  129.     chmod -R 777 data/ uc_server/ config/ uc_client/
  130.     /usr/local/apache2/bin/apachectl restart
  131.     mysql -uroot -p123456 -e "create database discuz;"
  132.     mysql -uroot -p123456 -e "grant all on discuz.* to discuz@'localhost' identified by '123456';"
  133.    
  134. }

  135. case $1 in
  136.     apache)
  137.     httpd_install
  138.     ;;
  139.     mysql)
  140.     mysql_install
  141.     ;;
  142.     php)
  143.     php_install
  144.     ;;
  145.     discuz)
  146.     dis_install
  147.     ;;
  148.     all)
  149.     httpd_install
  150.     mysql_install
  151.     php_install
  152.     dis_install
  153.     ;;
  154.     *)
  155.     echo "usage:apache|mysql|php|discuz|all]"
  156.     ;;
  157. esac

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