您的位置:首页 > 运维架构 > Shell

shell script自动搭建简单的lamp环境

2013-03-04 17:33 375 查看
#!/bin/bash

LPATH=/root/LAMP/

ZNED_VER="3.3.3-linux-glibc23-i386"

yum install gcc gcc-c++ make -y &> /dev/null

###################libxml2######################

cd $LPATH

tar -axf libxml2-2.6.30.tar.gz -C /usr/local/src/

cd /usr/local/src/libxml2-2.6.30

./configure --prefix=/usr/local/libxml2/

make

make install

###################libmcrypt##############

cd $LPATH

tar -axf libmcrypt-2.5.8.tar.gz -C /usr/local/src/

cd /usr/local/src/libmcrypt-2.5.8

./configure --prefix=/usr/local/libmcrypt/

make

make install

cd /usr/local/src/libmcrypt-2.5.8/libltdl

./configure --enable-ltdl-install

make

make install

####################zlib###################

cd $LPATH

tar -axf zlib-1.2.3.tar.gz -C /usr/local/src/

cd /usr/local/src/zlib-1.2.3

./configure

make

make install

####################libpng######################

cd $LPATH

tar -axf libpng-1.2.31.tar.gz -C /usr/local/src/

cd /usr/local/src/libpng-1.2.31

./configure --prefix=/usr/local/libpng/

make

make install

#####################jpeg#######################

mkdir /usr/local/jpeg6

mkdir /usr/local/jpeg6/bin

mkdir /usr/local/jpeg6/lib

mkdir /usr/local/jpeg6/include

mkdir -p /usr/local/jpeg6/man/man1

cd $LPATH

tar -axf jpegsrc.v6b.tar.gz -C /usr/local/src/

cd /usr/local/src/jpeg-6b

./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static

make

make install

####################freetype#####################

cd $LPATH

tar -axf freetype-2.3.5.tar.gz -C /usr/local/src/

cd /usr/local/src/freetype-2.3.5

./configure --prefix=/usr/local/freetype/

make

make install

####################autoconf##########################3

cd $LPATH

tar -axf autoconf-2.61.tar.gz -C /usr/local/src/

cd /usr/local/src/autoconf-2.61

./configure

make

make install

###################gd-2#############################

cd $LPATH

tar -axf gd-2.0.35.tar.gz -C /usr/local/src/

cd /usr/local/src/gd-2.0.35

./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype/

make

make install

###############httpd#################

cd $LPATH

tar -axf httpd-2.2.9.tar.gz -C /usr/local/src/

cd /usr/local/src/httpd-2.2.9

./configure --prefix=/usr/local/apache2/ --with-included-apr --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support

#./configure --prefix=/usr/local/apache2/ --sysconfdir=/etc/httpd/ --with-included-apr --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support

make

make install

/usr/local/apache2/bin/apachectl start

echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.sysinit

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

ed -s /usr/local/apache2/conf/httpd.conf<<EOF

g/DirectoryIndex index.html/s/DirectoryIndex index.html/DirectoryIndex index.html index.php/g

w

q

EOF

###################ncurses###################

cd $LPATH

tar -axf ncurses-5.6.tar.gz -C /usr/local/src/

cd /usr/local/src/ncurses-5.6

./configure --with-shared --without-debug --without-ada --enable-overwrite

make

make install

####################mysql#######################

groupadd mysql

useradd -g mysql mysql

cd $LPATH

tar -axf mysql-5.0.41.tar.gz -C /usr/local/src/

cd /usr/local/src/mysql-5.0.41

./configure --prefix=/usr/local/mysql/ --with-extra-charsets=all

make

make install

cp support-files/my-medium.cnf /etc/my.cnf

/usr/local/mysql/bin/mysql_install_db --user=mysql

chown -R root /usr/local/mysql

chown -R mysql /usr/local/mysql/var

chgrp -R mysql /usr/local/mysql

/usr/local/mysql/bin/mysqld_safe --user=mysql &

cp /usr/local/src/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld

chown root.root /etc/rc.d/init.d/mysqld

chmod 755 /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

chkconfig --list mysqld

chkconfig --levels 245 mysqld off

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

###################php-5####################

cd $LPATH

tar -axf php-5.2.6.tar.gz -C /usr/local/src/

yum install libtool-* -y &> /dev/null

cd /usr/local/src/php-5.2.6

./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets

make

make install

cp /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf.bak

cp php.ini-dist /usr/local/php/etc/php.ini

echo "AddType application/x-httpd-php .php .phtml" >> /usr/local/apache2/conf/httpd.conf

grep index.html /usr/local/apache2/conf/httpd.conf |sed -i 's/"DirectoryIndex index.html"/"DirectoryIndex index.html index.php"/' /usr/local/apache2/conf/httpd.conf

/usr/local/apache2/bin/apachectl restart

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

#####################Zend####################

cd $LPATH

mkdir /usr/local/zend

tar -axf ZendOptimizer-$ZNED_VER.tar.gz -C /usr/local/src/

cd /usr/local/src/ZendOptimizer-$ZNED_VER/data/5_2_x_comp/

cp ZendOptimizer.so /usr/local/zend/

cp /usr/local/php/etc/php.ini /usr/local/php/etc/php.ini.bak

cat <<EOF > /usr/local/php/etc/php.ini

[Zend Optimizer]

zend_optimizer.optimization_level=1

zend_extension="/usr/local/zend/ZendOptimizer.so"

EOF

cat /usr/local/php/etc/php.ini.bak >> /usr/local/php/etc/php.ini

/usr/local/apache2/bin/apachectl restart
本文出自 “无咎” 博客,请务必保留此出处http://perofu.blog.51cto.com/6061242/1144601
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: