本文共 6235 字,大约阅读时间需要 20 分钟。
#!/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 variableH_FILES=httpd-2.2.29. tar .gzH_FILES_DIR=httpd-2.2.29H_URL= 'http://mirror.bit.edu.cn/apache/httpd/'H_PREFIX= '/usr/local/apache'###Mysql define path variableM_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 variableP_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 variableD_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 ]; thenecho 'Error,Just for Super user.'exit 2fi###Only one arguementif [ $ # -ne 1 ];thenecho -e "/e[31mPlease exec $0 --help/e[0m"exit 2fi###Must have arguement!if [ -z "$1" ]; thenecho -e "/e[31mPlease exec $0 --help/e[0m"exit 2fi###Help and Menuif [[ "$1" == '--help' ]]; thenecho -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"exitfi###Must correct option!if [[ "$1" -lt 1 || "$1" -gt 6 ]]; thenecho -e "/e[31mPlease exec $0 --help/e[0m"exit 2fi#####################################################################################################################################################################################################################################Install Apacheif [[ "$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" ]; thenecho -e '/e[32mApache Server Install Success!/e[0m'elseecho -e '/e[31mApache Server Install Failure!/e[0m'fiexitfi#############################################Install Mysql DBif [[ "$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 installif [ "$?" - eq "0" ]; thenecho -e '/e[32mMysql Server Install Success!/e[0m'elseecho -e '/e[31mMysql Server Install Failure!/e[0m'fiexitfi#############################################Configure Mysqlif [[ "$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 userid mysql> /dev/null 2>&1 || useradd mysqlcd $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 ]; thenecho -e '/e[32mMysql Server Configure Success!/e[0m'elseecho -e '/e[31mMysql Server Configuue Failure!/e[0m'fiexitfi#############################################Install Phpif [[ "$1" - eq "4" ]]; thenwget -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 ]; thenecho -e '/e[32mPhp Install Success!/e[0m'elseecho -e '/e[31mPhp Install Failure!/e[0m'fiexitfi############################################# Integrate Php and Mysqlif [[ "$1" - eq "5" ]]; thensed -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 .confif [ $? - eq 0 ]; thenecho -e '/e[32mIntegrate is Success!/e[0m'elseecho -e '/e[31mIntegrate is Failure!/e[0m'fi$H_PREFIX /bin/apachectl start > /dev/null 2>&1exitfi#############################################Configure Discuzif [[ "$1" - eq "6" ]]; thenwget -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 ]; thenecho -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 ]; thenecho -e '/e[32mDiscuz Mysql Configure Success!/e[0m'elseecho -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>&1if [ $? - eq 0 ]; thenecho -e '/e[32mApache and Mysql Start Success!/e[0m'elseecho -e '/e[31mApache and Mysql Start Failure!/e[0m'fielseecho -e '/e[31mConfigure Discuz Failure!/e[0m'fiexitfi
提醒:
运行脚本请先 #./Auto_Install_Discuz --help
如果要安装Discuz!尽量按编号顺序执行!
Server上的Selinux与Iptables是关闭的,并且环境包都已经yum安装完毕,包含但不限于以下软件
apr-devel,apr-util-devel,gcc,ncurses-devel,gcc-c++,libxml2,libxml2-devel..
当安装完成后便可以直接输入Server的IP直接安装Discuz论坛,如下:
注意这里要和脚本中定义的数据库名、授权的用户名、密码一致
执行安装!
安装完毕!
转载地址:http://iyjdl.baihongyu.com/