码迷,mamicode.com
首页 > 其他好文 > 详细

lamp环境一键部署

时间:2016-03-19 06:41:24      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:lamp   lamp环境   lamp一键部署   

#!/bin/bash

#tangbo

#QQ 79313760

libs="gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel pcre pcre-devel gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake  gcc-devel gcc-c++-devel autoconf* automake*ncurses  libtool* cmake  bison bison-devel unzip"


yum -y install $libs


#mkdir dirctory

soft_dir="/var/soft"

if [ ! -d $soft_dir ]

then

mkdir $soft_dir

fi

#mkdir mysql install and data

mkdir /usr/local/mysql

mkdir /usr/local/data

chown -R mysql.mysql /usr/local/mysql

chown -R mysql.mysql /usr/local/data

 


#代码上传,并解压

echo "请上传软件源码至 $soft_dir,完成后输入ok:"

read stat

if [ $stat == "ok" ]

then

        echo "输入需要安装的软件包,以空格分隔:"

        read list_tmp

        cd $soft_dir

        echo $list_tmp

        for sft_temp in `echo $list_tmp`

        do

                sft=`ls | grep $sft_temp`

                /bin/tar -zxvf $sft 1>/dev/null 2>&1

                /bin/tar -jxvf $sft 1>/dev/null 2>&1

                echo "$sft 解压完成"

        done

else

        echo "请输入ok"

fi


#编译安装

home_dir=/usr/local


add_usr() {

groupadd $1

useradd -M -s  /sbin/nologin -g $1 $2

}


get_dir() {

b_name=$1

cd $soft_dir

b_dir=`ls | grep $b_name | grep -v tar`

}


#3、安装apache

cd $soft_dir

for mk_temp in `echo $list_tmp`

do

case $mk_temp in

#1、安装apr

apr-1.5.1)

# add_usr www www

get_dir $mk_temp

cd $b_dir

./configure --prefix=/usr/local/apr &>/dev/null && make && make install && echo "$mk_temp安装完成" 

;;

#2、安装apr-util

apr-util-1.5.4)

# add_usr www www

get_dir $mk_temp

cd $b_dir

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr &>/dev/null && make && make install && echo "$mk_temp安装完成" 

;;

httpd-2.4.16)

add_usr www www

get_dir $mk_temp

cd $b_dir

./configure  --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event &>/dev/null && make && make install && echo "$mk_temp安装完成" 

                chkconfig --add httpd

                chkconfig httpd  on

          ;;

mysql-5.6.20)

add_usr mysql mysql

get_dir $mk_temp

cd $b_dir && echo "$b_dir"

                cmake \

               -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

               -DMYSQL_DATADIR=/usr/local/data \

               -DSYSCONFDIR=/etc \

               -DWITH_MYISAM_STORAGE_ENGINE=1 \

               -DWITH_INNOBASE_STORAGE_ENGINE=1 \

               -DWITH_MEMORY_STORAGE_ENGINE=1 \

               -DWITH_READLINE=1 \

               -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \

               -DMYSQL_TCP_PORT=3306 \

               -DENABLED_LOCAL_INFILE=1 \

               -DWITH_PARTITION_STORAGE_ENGINE=1 \

               -DEXTRA_CHARSETS=all \

               -DDEFAULT_CHARSET=utf8 \

               -DDEFAULT_COLLATION=utf8_general_ci \

               -DMYSQL_USER=mysql && make && make install && echo "$mk_temp安完成" 

         cd /usr/local/mysql/scripts/ && ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/data

         cd /usr/local/mysql/support-files

         cp mysql.server /etc/rc.d/init.d/mysql

         cp my-default.cnf /etc/my.cnf

ln -s /usr/local/mysql/bin/* /usr/bin/

         chkconfig --add mysql

         chkconfig mysql on 

;;


libmcrypt-2.5.7)

#               add_usr www www

                get_dir $mk_temp

                cd $b_dir

                ./configure &>/dev/null && make && make install && echo "$mk_temp安装完成"

;;


php-5.6.0)

#               add_usr www www

                get_dir $mk_temp

                cd $b_dir

                ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql  --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config  --enable-mbstring  --with-freetype-dir  --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts --with-mcrypt   &>/dev/null && make && make install && echo "$mk_temp安装完成"

;;

*)

echo "Usage:{apr-1.5.1 apr-util-1.5.4 httpd-2.4.16 mysql-5.6.20}"

exit 1

;;

esac

done


本文出自 “山猫” 博客,谢绝转载!

lamp环境一键部署

标签:lamp   lamp环境   lamp一键部署   

原文地址:http://cqtangbo.blog.51cto.com/2978612/1752659

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!