安装lamp+discuz脚本

#!/bin/bash
#by 2015-7-25--lijq
#directiof for use:源码包和脚本在同一目录且在root目录下的文件里
DIR=/mnt/soft/
SCRIPT_DIR=/root/autolamp
        if [ $UID -ne 0 ]; then
        echo -e "\033[32monly for root to install this LAMP\033[0m"
                exit 3
        fi
        echo -e "\033[32mcreate soft dowload dir....\033[0m"
        if [ ! -d $DIR ];then
        mkdir -p $DIR;
        fi
        echo -e  "\033[32minstal some dependent packages,please wait for .... \033\0m"
        yum install gcc gcc-c++ make cmake ncurses-devel bison perl lrzsz epel-release pcre-devel openssl-devel -y;
        yum install wget unzip libxml2-devel libmcrypt-devel bzip2-devel libxml2-devel openssl-devel bzip2 bzip2-devel -y
;
APR_FILE=apr-1.5.2.tar.gz
APR=`echo $APR_FILE | sed ‘s/\.tar\.gz//g‘`
APR_UTILS=apr-util-1.5.2.tar.gz
APR_UTIL=`echo $APR_UTILS | sed ‘s/\.tar\.gz//g‘`
APACHE_FILE=httpd-2.4.16.tar.gz
APACHE=`echo $APACHE_FILE | sed ‘s/\.tar\.gz//g‘`
APR_DIR=/usr/local/apr/
APRUTIL_DIR=/usr/local/apr-util/
APACHE_DIR=/usr/local/apache/
function httpd_install()
{       if [ -f $APR_FILE -o -f $APR_UTILS -o -f $APACHE_FILE ];then
        cp $APR_FILE $APR_UTILS $APACHE_FILE $DIR -a

else
        cd $DIR;
        wget -c http://archive.apache.org/dist/apr/$APR_FILE;
        wget -c http://archive.apache.org/dist/apr/$APR_UTILS;
        wget -c http://www.apache.org/dist/httpd/$APACHE_FILE;
        fi
        cd $DIR
        tar xzvf $APR_FILE;
        cd $APR;./configure --prefix=$APR_DIR && make && make install;
        if  [ $? -eq 0  ]; then
        echo -e "\033[32mThis apr is install successfully...\033[0m"
        else
        echo -e "\033[32mThis apr is install failed,please check....\033[0m"
        exit
        fi
        cd $DIR;
        tar xzvf $APR_UTILS;
        cd $APR_UTIL;
        ./configure --prefix=$APRUTIL_DIR --with-apr=$APR_DIR &&make && make install;
        if [ $? -eq 0 ];then
        echo -e "\033[32mThis apr-util is install successfully....\033[0m"
        else
        echo -e "\033[32mThis arp in install failed, please check....\033[0m"
        exit
        fi
        cd $DIR;
        tar xzvf $APACHE_FILE; cd $APACHE;

./configure --prefix=$APACHE_DIR  --enable-so --enable-ssl --enable-cgi--enable-rewrite --with-zlib --with-pcre -
-with-apr=$APR_DIR --with-apr-util=$APRUTIL_DIR --enable-modules=most --enable-mpms-shared=all --with-mpm=event && make &
& make install
        if [ $? -eq 0 ]; then
        echo -e "\033[32mThe apache is install successful..\033[0m"
        $APACHE_DIR/bin/apachectl restart;
        else
        echo -e "\033[32mTHE apache is install failed,please check....\033[0m"
        exit
        fi
}
        sleep 3
MYSQL_FILE=‘mysql-5.5.44.tar.gz‘
MYSQL=`echo $MYSQL_FILE | sed ‘s/\.tar\.gz//g‘`
DATADIR=/data/mysql3306
BASEDIR=/data/app/mysql3306
MYSQL_STATUS=`ps -ef |grep mysqld_safe |awk ‘NR==1 {print $9}‘ |sed ‘s#\/data\/app\/mysql3306\/bin\/##g‘`
function mysql_install()
{       cd $SCRIPT_DIR ;
        if [ -f "$MYSQL_FILE" ];then
        cp  ${MYSQL_FILE} $DIR -a ;
        sleep 2
        else
        cd $DIR;
        wget -c  http://download.softagency.net/MySQL/Downloads/MySQL-5.5/$MYSQL_FILE;
        fi
        cd $DIR;
        tar xzvf $MYSQL_FILE;cd $MYSQL;mkdir -p {$DATADIR,$DATADIR};

cmake \-DCMAKE_INSTALL_PREFIX=$BASEDIR \-DMYSQL_DATADIR=$DATADIR \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE
_STORAGE_ENGINE=1 \-DWITH_MEMORY_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DMYSQL_TCP_PORT=3306 \-DENABLED_LOCAL_INFILE=1 \-D
WITH_PARTITION_STORAGE_ENGINE=1 \-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DWIT
H_DEBUG=0 \-DMYSQL_USER=mysql \-DMYSQL_UNIX_ADDR=$DATADIR/mysql3306.sock && make && make install
         if [ $? -eq 0 ]; then
        echo -e "\033[32mthe mysql is install successful..\033[0m"
        else
        echo -e "\033[32mThis  mysql is install failed.....\033[0m"
        exit 2
        fi
        useradd mysql;
        chown -R  mysql.mysql $DATADIR;
        chown -R mysql:mysql $BASEDIR;
        cp -a support-files/my-large.cnf $DATADIR/my.cnf;
        chown -R  mysql.mysql $DATADIR/my.cnf;
        cp -a $BASEDIR/support-files/mysql.server /etc/init.d/mysqld;
#       sed  -i ‘/mysql3306/i datadir = /data/mysql3306\nbasedir = /data/app/mysql3306‘ /data/mysql3306/my.cnf;
        sed -i "26a\datadir = $DATADIR\nbasedir = $BASEDIR" $DATADIR/my.cnf;
        cd $BASEDIR;./scripts/mysql_install_db --basedir=$BASEDIR --datadir=$DATADIR --user=mysql;
echo "export PATH="\$PATH":${BASEDIR}/bin/" >>/root/.bash_profile && source /root/.bash_profile && /etc/init.d/mysqld res
tart;pkill mysql;/etc/init.d/mysqld start;/etc/init.d/mysqld restart;
        sleep 5
        if [ ${MYSQL_STATUS} = ‘mysqld_safe‘ ];then
        echo -e "\033[32mThe Mysql was installed successfully....\033[0m"
        else
        echo -e "\033[31mThe Mysql is installed failed,Please check...\033[0m"
        exit

fi
        sleep 3

}
PHP_FILES=php-5.4.42.tar.bz2
PHP=`echo $PHP_FILES | sed ‘s/\.tar\.bz2//g‘`
PHP_DIR=/usr/local/php
function php_install()
{       cd $SCRIPT_DIR;
        if [ -f $PHP_FILES ];then
        cp $PHP_FILES $DIR -a ;
        else
        cd $DIR;
        wget http://mirrors.sohu.com/php/$PHP_FILES;
        fi
        cd $DIR;
        if [ -d $BASEDIR ] ; then
        tar xjvf $PHP_FILES ; cd $PHP;./configure --prefix=$PHP_DIR --with-mysql=$BASEDIR --with-openssl --with-mysqli=$B
ASEDIR/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-di
r=/usr --enable-xml --enable-sockets --enable-fpm --with-mcrypt --with-bz2 --with-config-file-path=/etc/php/php.ini --wit
h-config-file-scan-dir=/etc/php/php.d/ --with-apxs2=${APACHE_DIR}bin/apxs && make && make install
        else
        echo -e "\033[32mplease install this mysql....\033[0m"
        fi
        if [ $? -eq 0 ]; then
        echo -e "\033[32mthe php is install successful..\033[0m"

else
        echo "the php is install failed,,,,please quit"
        exit
        fi
}

IP=`ifconfig eth0 |grep Bcast |awk ‘{print $2}‘|sed ‘s/addr://g‘`
function php_apache()
{
        echo -e "\033[32mIt will configure the Apache and PHP\033[0m"
        cp ${APACHE_DIR}conf/httpd.conf ${APACHE_DIR}conf/httpd.conf.bak
        echo "Addtype application/x-httpd-php  .php" >> ${APACHE_DIR}conf/httpd.conf
        sed -i ‘s/DirectoryIndex index.html/DirectoryIndex index.php index.html/g‘ ${APACHE_DIR}conf/httpd.conf
        if [ $? -eq 0 ];then
        echo -e "\033[32mIt‘s successfully, Will test the PHP... \033[0m"
        rm -rf ${APACHE_DIR}htdocs/*;
         cat >${APACHE_DIR}htdocs/index.php <<EOF
<?php
phpinfo();
?>
EOF
        if [ $? -eq 0 ];then
#启动apache服务
        ${APACHE_DIR}bin/apachectl restart ;
        ${APACHE_DIR}bin/apachectl restart ;
        echo -e "\033[32mYou can access http://${IP}/index.php\033[0m"

fi
        else
        echo -e "\033[31mThe PHP is installed failed,Please check...\033[0m"
        exit
        fi
}
Discuz_file=Discuz_X3.1_SC_UTF8.zip
Discuz=Discuz_X3.1_SC_UTF8
PASSWORD=123456
function discuz_install()
{       cd $SCRIPT_DIR;
        if [ -f $Discuz_file ];then
        cp $Discuz_file $DIR -a ;
        sleep 2
        else
        cd $DIR;
        wget -c http://download.comsenz.com/DiscuzX/3.1/$Discuz_file;
        fi
        cd $DIR;
        rm -rf ${APACHE_DIR}htdocs/* && unzip $Discuz_file -d ${APACHE_DIR}htdocs/ ;
        cd ${APACHE_DIR}htdocs/ && mv upload/* . && chmod -R o+w data/ config/ uc_server/ uc_client/;
        if [ $? -eq 0 ];then
        echo -e ‘\033[32mThis discuz is files configure ok....\033[0m‘
#设置数据库密码和创建数据库
        $BASEDIR/bin/mysqladmin -uroot password $PASSWORD &&
        mysql -uroot -h 127.0.0.1 -p$PASSWORD -e "create database discuz;"&&
#授权discuz用户
        mysql -uroot -h 127.0.0.1 -p$PASSWORD -e "grant all on *.* to [email protected]‘${IP}‘ identified by ‘$PASSWORD‘;flush priv
ileges;"

if [ $? -eq 0 ];then
        echo -e "\033[32mThis discuz  database configure is  success.....\033[0m"
        else
        echo -e "\033[32mThis discuz database configure is failed..please check..\033[0m"
        fi
#重启apache服务和mysql
        ${APACHE_DIR}bin/apachectl restart&& /etc/init.d/mysqld restart;
        if [ $? -eq 0 ];then
        echo -e "\033[32mThe apache and Mysql Start Success!\033[0m"
        else
        echo -e "\033[31mThis discuz configure is failed..please check.\033[0m"
        fi
        else
        echo -e  "\033[32mThe mysql and apache is failed....please check.\033[0m"
        echo -e  "\033[32mThis discuz is install success.......\033[32m"
        exit 2
        fi
}
PS3="please select your install menu:"
        select i in "httpd" "mysql" "php" "php+apache" "discuz" "quit" "all_auto"
        do
        case $i in
        httpd )
        httpd_install
        ;;
        mysql )
        mysql_install
        ;;

php )
        php_install
        ;;
        php+apache )
        php_apache
        ;;
        discuz )
        discuz_install
        ;;
        all_auto )
        httpd_install;
        mysql_install;
        php_install;
        php_apache;
        discuz_install
        ;;
        quit )
        exit
        ;;
        * )
        echo "Usage: $0 {httpd|mysql|php|php+apache|discuz|all_auto|quit}"
esac
        done

时间: 2024-12-07 16:11:53

安装lamp+discuz脚本的相关文章

源码安装LAMP+Discuz

Apache 安装步骤: 说明:操作系统CentOS release 6.5 (Final)内核版本:2.6.32-431.el6.x86_64 1,准备的软件:apr-1.5.2.tar.gz.apr-util-1.5.4.tar.gz.httpd-2.4.18.tar.gz.mysql-5.5.32.tar.gz.pcre-8.38.tar.gz.php-5.6.20.tar.gz [[email protected] /]#yum -y install gcc gcc-c++ make n

yum安装lamp+discuz

首先安装httpd 相关软件包 yum install httpd httpd-devel httpd-manual httpd-tools -y 启动httpd服务 service httpd restart 将httpd服务添加到开机自启动 chkconfig httpd on 此时在浏览器中输入本机ip已经能打开apache测试网站,注意修改防火墙策略 安装mysql yum install mysql mysql-devel php-mysql mysql-server -y 将mysq

CentOS 6.9 yum方式安装LAMP环境,并部署Discuz

一.安装LAMP环境: # yum -y install httpd mysql-server php-mysql php 程序包名称及版本: httpd:2.2.15 mysql-server:5.1.73 php-mysql(php连接mysql时需要用到的驱动):5.3.3 php:5.3.3 httpd配置文件: ?  主配置文件:/etc/httpd/conf/httpd.conf ?  辅助配置文件:/etc/httpd/conf.d/*.conf mysql配置文件:/etc/my

安装lamp脚本

#!/bin/bash #2017-8-21 14:24:26 #author  guojuwnei #descrption  源码安装lamp,Case+Select+函数 #Httpd 常量定义 H_URL=http://mirror.bit.edu.cn/apache/httpd/ H_FILES=httpd-2.2.34.tar.gz H_FILES_DIR=httpd-2.2.34 H_PREFIX=/usr/local/apache #Mysql 常量定义 M_URL=https:/

一键自动化安装LAMP脚本(用系统自带的yum源安装)

声明 作者:昨夜星辰 博客:http://yestreenstars.blog.51cto.com/ 本文由本人创作,如需转载,请注明出处,谢谢合作! 目的 用系统自带的yum源安装LAMP. 环境 OS:CentOS 6.6 32 服务端配置 #!/bin/bash # Script Name: One-key Automatic Install LAMP Server # Author: yestreenstars # Create Time: 2014-12-30 # Update Tim

一键自动化安装LAMP脚本(用第三方yum源安装)

声明 作者:昨夜星辰 博客:http://yestreenstars.blog.51cto.com/ 本文由本人创作,如需转载,请注明出处,谢谢合作! 目的 用第三方的yum源安装LAMP(软件版本较新). 环境 OS:CentOS 6.6 32 服务端配置 #!/bin/bash #!/bin/bash # Script Name: One-key Automatic Install LAMP Server # Author: yestreenstars # Create Time: 2014

编译安装LAMP(两种场景)

编译安装LAMP 场景一:AP组合以模块方式结合(编译PHP作为httpd的模块):进而完成虚拟主机PMA(phpmyadmin)和discuz论坛 场景二:AP组合以fpm方式,PHP独立守护进程运行:进而完成虚拟主机PMA(phpmyadmin)和discuz论坛 ==========================场景一============================ 拓扑结构: 主机一 网卡1IP为172.20.1.100 网卡2IP为192.168.217.219 在此计算机上

基于编译安装LAMP架构---模块化

一.程序包和安装环境准备 1.程序版本: apr-1.5.0.tar.bz2 apr-util-1.5.3.tar.bz2 httpd-2.4.10.tar.bz2 mariadb-5.5.43-linux-x86_64.tar.gz php-5.6.4.tar.xz phpMyAdmin-4.0.5-all-languages.zip Discuz_X3.2_SC_GBK.zip 2.准备安装开发环境 yum groupinstall  "Server Platform Development

fcgi模式下编译安装LAMP+xcache

php的工作模式: php在lamp环境下共有三种工作模式:CGI模式.apache模块.FastCGI模式.CGI模式下运行PHP,性能不是很好.作为apache的模块方式运行,在以前的课程中编译安装lamp已经介绍过了.FastCGI的方式和apache模块的不同点在于:FastCGI方式PHP是一处独立的进程,所有PHP子进程都由PHP的一个叫作php-fpm的组件负责管理:而apache模块化方式运行的PHP,则是apache负责调用PHP完成工作.PHP的FastCGI方式性能要比ap