linux安装驱动shell脚本,Linux Shell十一 脚本安装Discuz

#!/bin/bash

#

#Target: Auto install Discuz!

#Date: 2015-05-02

#Author: Jacken

#QQ:654001593

#QQ Group:170544180

#Version: 1.0

#You should check apr-devel,apr-util-devel,gcc,ncurses-devel,gcc-c++,libxml2,libxml2-devel...before exec script

#You can use yum to install!

#

#

#Httpd define path variable

H_FILES=httpd-2.2.29. tar .gz

H_FILES_DIR=httpd-2.2.29

H_URL= 'http://mirror.bit.edu.cn/apache/httpd/'

H_PREFIX= '/usr/local/apache'

#

#

#Mysql define path variable

M_FILES= 'mysql-5.1.63.tar.gz'

M_FILES_DIR= 'mysql-5.1.63'

M_URL= 'http://downloads.mysql.com/archives/mysql-5.1/'

M_PREFIX= '/usr/local/mysql'

#

#

#Php define path variable

P_FILES= 'php-5.3.28.tar.bz2'

P_FILES_DIR= 'php-5.3.28'

P_URL= 'http://mirrors.sohu.com/php/'

P_PREFIX= '/usr/local/php5'

#

#

#Discuz define path variable

D_FILES= 'Discuz_X3.2_SC_UTF8.zip'

D_URL= 'http://download.comsenz.com/DiscuzX/3.2/'

D_DIR= '/var/www/html'

#

#

#Only for super user to execute!

if      [ $UID - ne      0 ]; then

echo      'Error,Just for Super user.'

exit      2

fi

#

#

#Only one arguement

if      [ $ # -ne 1 ];then

echo      -e  "/e[31mPlease exec $0 --help/e[0m"

exit      2

fi

#

#

#Must have arguement!

if      [ -z  "$1"       ]; then

echo      -e  "/e[31mPlease exec $0 --help/e[0m"

exit      2

fi

#

#

#Help and Menu

if      [[  "$1"      ==  '--help'      ]]; then

echo      -e  '/e[31mPlease Select Install Menu follow:/e[0m'

echo      -e  '/e[32m1  Install Apache/e[0m'

echo      -e '/e[33m2  Install Mysql/e[0m'

echo      -e  '/e[34m3  Configure Mysql/e[0m'

echo      -e  '/e[35m4  Install Php/e[0m'

echo      -e '/e[36m5  Integrate Php and Mysql/e[0m'

echo      -e  '/e[37m6  Configure Discuz/e[0m'

echo      -e  "/e[31mThe Usage: $0 1 or 2 or 3 or 4 or 5 or 6,Only one number/e[0m"

exit

fi

#

#

#Must correct option!

if      [[  "$1"      -lt 1 ||  "$1"      -gt 6 ]]; then

echo      -e  "/e[31mPlease exec $0 --help/e[0m"

exit      2

fi

##################################################################################################################

##################################################################################################################

#Install Apache

if      [[  "$1"      - eq      "1"      ]]; then

wget -c $H_URL$H_FILES &&  tar      -zxf $H_FILES &&  cd      $H_FILES_DIR && . /configure      --prefix=$H_PREFIX &&  make      &&  make      install

if      [  "$?"      - eq      "0"      ]; then

echo      -e  '/e[32mApache Server Install Success!/e[0m'

else

echo      -e  '/e[31mApache Server Install Failure!/e[0m'

fi

exit

fi

######################

######################

#Install Mysql DB

if      [[  "$1"      - eq      "2"      ]]; then

wget -c $M_URL$M_FILES &&  tar      -zxf $M_FILES &&  cd      $M_FILES_DIR && . /configure      --prefix=$M_PREFIX -- enable -assembler &&  make      &&  make      install

if      [  "$?"      - eq      "0"      ]; then

echo      -e   '/e[32mMysql Server Install Success!/e[0m'

else

echo      -e  '/e[31mMysql Server Install Failure!/e[0m'

fi

exit

fi

######################

######################

#Configure Mysql

if      [[  "$1"      - eq      "3"      ]]; then

/ cp      ${M_PREFIX} /share/mysql/my-medium .cnf   /etc/my .cnf && / cp      ${M_PREFIX} /share/mysql/mysql .server  /etc/init .d /mysqld      &&  chkconfig --add mysqld && chkconfig --level 345 mysqld on

#Useradd mysql user

id      mysql> /dev/null      2>&1 ||  useradd      mysql

cd      $M_PREFIX

chown      -R mysql.mysql $M_PREFIX && ${M_PREFIX} /bin/mysql_install_db      --user=mysql >  /dev/null      2>&1 &&

chown      -R mysql var &&  /usr/local/mysql/bin/mysqld_safe      --user=mysql& >  /dev/null      2>&1 &&

if      [ $? - eq      0 ]; then

echo      -e  '/e[32mMysql Server Configure Success!/e[0m'

else

echo      -e  '/e[31mMysql Server Configuue Failure!/e[0m'

fi

exit

fi

######################

######################

#Install Php

if      [[  "$1"      - eq      "4"      ]]; then

wget -c $P_URL$P_FILES &&  tar      -jxf $P_FILES &&  cd      $P_FILES_DIR && . /configure       --prefix=$P_PREFIX  --with-config- file -path=${P_PREFIX} /etc       --with-apxs2=${H_PREFIX} /bin/apxs      --with-mysql=$M_PREFIX &&  make      &&  make      install

if      [ $? - eq      0 ]; then

echo      -e  '/e[32mPhp Install Success!/e[0m'

else

echo      -e  '/e[31mPhp Install Failure!/e[0m'

fi

exit

fi

######################

######################

# Integrate Php and Mysql

if      [[  "$1"      - eq      "5"      ]]; then

sed      -i  '311a AddType     application/x-httpd-php .php'      $H_PREFIX /conf/httpd .conf &&

sed      -i  's/index.html/index.php index.html/'      $H_PREFIX /conf/httpd .conf

if      [ $? - eq      0 ]; then

echo      -e  '/e[32mIntegrate is Success!/e[0m'

else

echo      -e  '/e[31mIntegrate is Failure!/e[0m'

fi

$H_PREFIX /bin/apachectl      start > /dev/null      2>&1

exit

fi

######################

######################

#Configure Discuz

if      [[  "$1"      - eq      "6"      ]]; then

wget -c $D_URL$D_FILES && unzip $D_FILES -d $H_PREFIX /htdocs/      &&  cd      $H_PREFIX /htdocs/      && / mv      upload/* . &&  chmod      -R o+w data/ config/ uc_server/ uc_client/

if      [ $? - eq      0 ]; then

echo      -e  '/e[32mConfigure Discuz Success!/e[0m'      &&

#Create discuz database

$M_PREFIX /bin/mysql      -uroot -e  'create database discuz'      &&

#Grant user password

$M_PREFIX /bin/mysql      -uroot -e  "grant all on *.* to discuz@'localhost' identified by 'discuz'"      &&

#Flush privileges

$M_PREFIX /bin/mysql      -uroot -e  'flush privileges'

if      [ $? - eq      0 ]; then

echo      -e  '/e[32mDiscuz Mysql Configure Success!/e[0m'

else

echo      -e  '/e[31mDiscuz Mysql configure Failure!/e[0m'

fi

######################

######################

#Start Apache Server

$H_PREFIX /bin/apachectl      start> /dev/null      2>&1 &&

#Start Mysql Server

$M_PREFIX /bin/mysqld_safe      --user=mysql&> /dev/null      2>&1

if      [ $? - eq      0 ]; then

echo      -e  '/e[32mApache and Mysql Start Success!/e[0m'

else

echo      -e  '/e[31mApache and Mysql Start Failure!/e[0m'

fi

else

echo      -e  '/e[31mConfigure Discuz Failure!/e[0m'

fi

exit

fi

运行脚本请先 #./Auto_Install_Discuz --helphttps://www.cndba.cn/Expect-le/article/1637

如果要安装Discuz!尽量按编号顺序执行!

Server上的Selinux与Iptables是关闭的,并且环境包都已经yum安装完毕,包含但不限于以下软件https://www.cndba.cn/Expect-le/article/1637

apr-devel,apr-util-devel,gcc,ncurses-devel,gcc-c++,libxml2,libxml2-devel..https://www.cndba.cn/Expect-le/article/1637

https://www.cndba.cn/Expect-le/article/1637https://www.cndba.cn/Expect-le/article/1637

当安装完成后便可以直接输入Server的IP直接安装Discuz论坛,如下:

注意这里要和脚本中定义的数据库名、授权的用户名、密码一致

0ba7347ef3ab6bf4b4d170d4014aefca.pnghttps://www.cndba.cn/Expect-le/article/1637

执行安装!

安装完毕!

0c98d3532aa94ef374c0124c852b13b6.png

Done!https://www.cndba.cn/Expect-le/article/1637

https://www.cndba.cn/Expect-le/article/1637

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值