zoukankan      html  css  js  c++  java
  • LAMP动态网站安装脚本

      1 #!/bin/bash
      2 #auto make install LAMP
      3 #by authors zhangjianghua 2016
      4 
      5 #httpd define path variable
      6 H_FILES=httpd-2.2.17.tar.gz
      7 H_FILES_DIR=httpd-2.2.17
      8 H_PREFIX=/usr/local/httpd/
      9 
     10 #mysql define path variable
     11 M_FILES=mysql-5.5.22.tar.gz
     12 M_FILES_DIR=mysql-5.5.22
     13 M_PREFIX=/usr/local/mysql/
     14 
     15 
     16 #php define path variable
     17 
     18 P_FILES1=libmcrypt-2.5.8.tar.gz
     19 P_FILES_DIR1=libmcrypt-2.5.8
     20 P_PREFIX1=/usr/local/lib/
     21 
     22 P_FILES2=mhash-0.9.9.9.tar.gz
     23 P_FILES_DIR2=mhash-0.9.9.9
     24 P_PREFIX2=/usr/local/lib/
     25 
     26 P_FILES3=mcrypt-2.6.8.tar.gz
     27 P_FILES_DIR3=mcrypt-2.6.8
     28 P_PREFIX3=/usr/local/lib/
     29 
     30 P_FILES4=php-5.3.28.tar.gz
     31 P_FILES_DIR4=php-5.3.28
     32 P_PREFIX4=/usr/local/php/
     33 
     34 
     35 
     36 
     37 if [ -z "$1" ];then
     38         echo -e "33[36m请选择下面选项:33[0m"
     39         echo -e "33[32m1)编译安装Apache服务器33[1m"
     40         echo "2)编译安装MySQL服务器"
     41         echo "3)编译安装PHP服务器"
     42         echo "4)配置index.php并启动LAMP服务"
     43      echo "5)部署phpMyAdmin系统"
     44         echo -e "33[31m使用: { /bin/sh $0 1|2|3|4|help}33[0m"
     45         exit
     46 fi
     47 
     48 
     49 #auto install Apache
     50 if [ $1 -eq 1 ];then
     51         rpm -e httpd --nodeps
     52         tar -zxvf $H_FILES &&cd $H_FILES_DIR ;./configure --prefix=$H_PREFIX --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
     53 
     54         if [ $? -eq 0 ];then
     55                 make &&make install
     56                 echo -e "33[32mThe $H_FILES_DIR Server Install successfully!(Apache服务安装已完成!)33[0m"
     57         else
     58                 echo -e "33[32mThe $H_FILES_DIR Server Install failed,please check...33[0m"
     59                 exit
     60         fi
     61 fi
     62 
     63 #auto install Mysql
     64 if [ $1 -eq 2 ];then
     65         rpm -e mysql-server mysql --nodeps
     66         tar -zxvf cmake-2.8.6.tar.gz -C /usr/src/ && cd /usr/src/cmake-2.8.6/;./configure
     67         if [ $? -eq 0 ];then
     68                 gmake &&gmake install
     69                 echo -e "33[32mThe cmake Server Install successfully!(cmake编译安装完成!)33[0m"
     70         else
     71                 echo -e "33[31mThe cmake Server Install failed,please check...(cmake安装失败!)33[0m"
     72                 exit
     73         fi
     74         useradd -M -u 27 -s /sbin/nologin mysql
     75         cd /root
     76         tar -zxvf $M_FILES -C /usr/src/;cd /usr/src/$M_FILES_DIR && cmake -DCMAKE_INSTALL_PREFIX=$M_PREFIX -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
     77         if [ $? -eq 0 ];then
     78                 make &&make install
     79                 echo -e "33[32mThe mysql $M_FILES_DIR Install successfully!(MySQL服务安装已完成!)33[0m"
     80         else
     81                 echo -e "33[31mThe mysql $M_FILES_DIR Install failed,please check...(Mysql安装失败!)33[0m"
     82                 exit
     83         fi
     84         chown -R mysql:mysql /usr/local/mysql/
     85         cd /usr/src/$M_FILES_DIR
     86         cp support-files/my-medium.cnf /etc/my.cnf
     87         $M_PREFIX/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
     88         cd /usr/src/$M_FILES_DIR
     89         ln -s /usr/local/mysql/bin/* /usr/local/bin/
     90         cp support-files/mysql.server /etc/init.d/mysqld
     91         chmod +x /etc/rc.d/init.d/mysqld
     92         chkconfig --add mysqld
     93         chkconfig mysqld on
     94         service mysqld stop
     95         service mysqld start
     96         netstat -anpt | grep 3306
     97 fi
     98 
     99 
    100 
    101 #PHP define path variable
    102 
    103 if [ $1 -eq 3 ];then
    104         tar -zxvf $P_FILES1 -C /usr/src/;cd /usr/src/$P_FILES_DIR1/ && ./configure && make && make install && ln -s /$P_PREFIX1/libmcrypt.* /usr/lib/
    105         cd /root/
    106         tar -zxvf $P_FILES2 -C /usr/src/;cd /usr/src/$P_FILES_DIR2/ && ./configure && make && make install && ln -s /$P_PREFIX2/libmhash* /usr/lib/
    107         cd /root/
    108         tar -zxvf $P_FILES3 -C /usr/src/;cd /usr/src/$P_FILES_DIR3/ && export LD_LIBRARY_PATH=/$P_PREFIX3:$LD_LIBRARY_PATH && ./configure && make && make install
    109         cd /root/
    110         tar -zxvf $P_FILES4 -C /usr/src/;cd /usr/src/$P_FILES_DIR4/ && ./configure --prefix=$P_PREFIX4 --with-mcrypt --with-apxs2=$H_PREFIX/bin/apxs --with-mysql=$M_PREFIX --with-config-file-path=$P_PREFIX4 --enable-mbstring --enable-sockets
    111         if [ $? -eq 0 ];then
    112                 make &&make install
    113                 echo -e "33[32mThe $P_FILES_DIR4 Server Install successfully!(PHP安装已完成!)33[0m"
    114         else
    115                 echo -e "33[31mThe $P_FILES_DIR4 Server Install failed,please check...(PHP安装失败!)33[0m"
    116                 exit
    117         fi
    118 fi
    119 
    120 if [ $1 -eq 4 ];then
    121         sed -i '/DirectoryIndex/s/index.html/index.php index.html/g' $H_PREFIX/conf/httpd.conf
    122         echo "AddType   application/x-httpd-php .php" >>$H_PREFIX/conf/httpd.conf
    123         IP=`ifconfig eth0|grep "Bcast"|awk '{print $2}'|cut -d: -f2`
    124         echo "You can access http://$IP/"
    125 
    126 cat >$H_PREFIX/htdocs/index.php <<EOF
    127 <?php
    128 phpinfo();
    129 ?>
    130 EOF
    131 fi
    132 if [ $1 -eq 5 ];then
    133         tar -zxvf phpMyAdmin-4.2.5-all-languages.tar.gz
    134         mv phpMyAdmin-4.2.5-all-languages/ /usr/local/httpd/htdocs/phpMyAdmin
    135         cd /usr/local/httpd/htdocs/phpMyAdmin
    136         cp config.sample.inc.php config.inc.php
    137         if [ $? -eq 0 ];then
    138                 echo -e "33[32mphpMyAdmin系统安装完成!33[0m"
    139         else
    140                 echo -e "33[31mphpMyAdmin系统安装失败!33[0m"
    141         fi
    142 
    143 fi
    144 
    145       #  netstat -tnl
    146        # /usr/local/httpd/bin/apachectl -t
    147         #/usr/local/httpd/bin/apachectl start
    148         #ps -ef | grep http
    149          #       echo -e "33[32m配置完成,打开浏览器测试结果33[0m"
    150 
    151 #phpMyAdmin测试:fireorx http://192.168.1.1/phpMyAdmin &
    152                                                                                  
    个人备忘,欢迎阅读
  • 相关阅读:
    Single Image Dehazing via Conditional Generative Adversarial Network(CVPR2018-图像去雾)
    STF-GAN:Recovering Realistic Texture in Image Super-resolution by Deep Spatial Feature Transform (CVPR2018)
    os 模块
    Pytorch-get ready with me
    Python学习(第七章)
    Python学习(第六章)
    pytorch与opencv 安装(Linux)
    Python学习(第五章)
    Python学习(第四章)
    Python学习(第三章)
  • 原文地址:https://www.cnblogs.com/zhangjianghua/p/5691809.html
Copyright © 2011-2022 走看看