- 论坛徽章:
- 0
|
前言:我平时安装软件的脚本、只要安装过一遍、就能做一个脚本。而且可以对基本配置也可以实现自动化。不过最好是自己做的,这样当环境改变时就会很容易更改。
Author:Ajian
2007-10-28
#!/bin/sh
############################
##
## Author : Ajian
## Time : 2007-7-22
##
##autoinstall the LAMP system
#################################
##Set the varible.
echo -n "How to do with GD:(No-install[0],Install[1],delete[2]):"
read GD
echo -n "How to do with Apache:(No-install[0],Install[1],delete[2]):"
read Apache
echo -n "How to do with Mysql:(No-install[0],Install[1],delete[2]):"
read Mysql
echo -n "How to do with PHP:(No-install[0],Install[1],delete[2]):"
read PHP
echo -n "How to do with Memcached:(No-install[0],Install[1],delete[2]):"
read Memcached
echo -n "How to do with Squid:(No-install[0],Install[1],delete[2]):"
read Squid
echo -n "How to do with SVN:(No-install[0],Install[1],delete[2]):"
read SVN
echo -n "All software put in (/opt):"
read TAR_FILE
echo -n "All software tar in (/opt/software):"
read TAR_SOFT
echo -n "All software install in (/usr/local):"
read INS_SOFT
if [ "$TAR_FILE" = "" ];then
TAR_FILE="/opt"
fi
if [ "$TAR_SOFT" = "" ];then
TAR_SOFT="/opt/software"
fi
if [ "$INS_SOFT" = "" ];then
INS_SOFT="/usr/local"
fi
cd $TAR_FILE
if [ "$GD" = 1 ];then
#Install the zlib software
tar --directory $TAR_SOFT -zxvf zlib*.gz ; cd $TAR_SOFT/zlib*
./configure --shared --prefix=$INS_SOFT
make&&make install&&cd $TAR_FILE
echo "zlib is filished....."
#install the freetype
tar --directory $TAR_SOFT -zxvf freetype*.gz;cd $TAR_SOFT/freetype*
./configure --prefix=$INS_SOFT
make && make install&&cd $TAR_FILE
echo "freetype is filished......"
#install the libpng
tar --directory $TAR_SOFT -zxvf libpng*.gz;cd $TAR_SOFT/libpng*
./configure --prefix=$INS_SOFT
make check && make install&&cd $TAR_FILE
echo "libpng is filished......"
#install the jpegsrc
tar --directory $TAR_SOFT -zxvf jpegsrc*.tar;cd $TAR_SOFT/jpeg*
./configure --prefix=$INS_SOFT --enable-shared --enable-static
make test ; mkdir -p $INS_SOFT/man/man1 && make install;cd $TAR_FILE
echo "jpegsrc is filished......"
#install the gd
tar --directory $TAR_SOFT -zxvf gd*.tar ; cd $TAR_SOFT/gd*
./configure --prefix=$INS_SOFT/gd2 --enable-shared --enable-static --with-png=$INS_SOFT --with-freetype=$INS_SOFT --with-jpeg=$INS_SOFT
make && make install && cd $TAR_FILE
echo "gd is filished......"
elif [ "$GD" = 2 ]; then
echo "#######################################################################"
echo "Notice you are deleting the GD......"
# Delete the zlib
cd $TAR_SOFT/zlib*
make uninstall;make clean
#Delete the freetype
cd $TAR_SOFT/freetype*
make uninstall;make clean
#Delete the libpng
cd $TAR_SOFT/libpng*
make uninstall;make clean
#Delete the JPEG
cd $TAR_SOFT/jpeg*
rm -Rf $INS_SOFT/man/man1 ; make clean
#Delete the gd
make uninstall;make clean
rm -Rf $INS_SOFT/gd*
echo "Notic the GD is deleted."
fi
echo "#######################################################################"
if [ "$Apache" = 1 ];then
#install the apache
cd $TAR_FILE
tar --directory $TAR_SOFT -zxvf httpd*.gz;cd $TAR_SOFT/httpd*
./configure --prefix=$INS_SOFT/apache2 --enable-so --enable-dav --enable-rewrite --enable-deflate --enable-mem-cache --enable-cache
make &&make install&&cd $TAR_FILE
echo "apache is filished......"
#config the apache
echo "AddType application/x-httpd-php .php" >> $INS_SOFT/apache2/conf/httpd.conf
sed -i 's/DirectoryIndex index.html index.html.var/& index.htm index.php /g' $INS_SOFT/apache2/conf/httpd.conf
sed -i 's/\/usr\/local\/apache2\/htdocs/\/var\/www\/html/g' $INS_SOFT/apache2/conf/httpd.conf
#config the test web
echo " " > /var/www/html/phpinfo.php
/usr/local/apache2/bin/apachectl -k start
elif [ "$Apache" = 2 ] ;then
echo "################################################################"
echo "Notice you are deleting the Apache......"
cp /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.`data`
cd $TAR_SOFT/httpd*;make clean;rm -Rf $INS_SOFT/apache*
fi
echo "################################################################"
if [ "$Mysql" = 1 ];then
#install the mysql
tar --directory $INS_SOFT -zxvf mysql-*.gz ; cd $INS_SOFT ; mv mysql* mysql ;
groupadd mysql
useradd -g mysql mysql
cp support-files/my-medium.cnf /etc/my.cnf
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
chgrp -R mysql .
cd $TAR_FILE
echo "mysql is filished ......"
##config the mysql
/bin/cp $INS_SOFT/mysql/support-files/mysql.server /etc/init.d/mysqld
/sbin/chkconfig --add mysqld
elif [ "$Mysql" = 2 ];then
echo "#############################################################"
echo "Notice you are deleting the Mysql......"
rm -Rf $INS_SOFT/mysql*
userdel mysql
rm -f /etc/my.cnf
fi
echo "##################################################################"
if [ "$PHP" = 1 ];then
#install the php
tar --directory $TAR_SOFT -zxvf php*.gz ; cd $TAR_SOFT/php*
./configure --prefix=$INS_SOFT/php --with-gd=$INS_SOFT/gd2 --with-apxs2=$INS_SOFT/apache2/bin/apxs --with-xml --enable-sockets --with-zlib --with-jpeg-dir=$INS_SOFT --with-freetype-dir=$INS_SOFT --enable-gd-native-ttf --with-png-dir=$INS_SOFT --with-ttf --with-mysql=$INS_SOFT/mysql --disable-debug --enable-inline-optimization --enable-mm=shared
make && make install &&cd $TAR_FILE
echo "php is filished......"
##config the php
/bin/cp $TAR_SOFT/php*/php.ini-recommended /etc/php.ini
sed -i 's/register_globals = Off/register_globals = On/g' /etc/php.ini
sed -i 's/allow_url_include = Off/allow_url_inclue = On/g' /etc/php.ini
elif [ "$PHP" = 2 ];then
echo "################################################################"
echo "Notice you are deleting the PHP......"
rm -Rf $INS_SOFT/php*
rm -f /etc/php.ini
fi
echo "#############################################################"
if [ "$Memcached" = 1 ];then
#install the libevent...
tar --directory $TAR_SOFT -zxvf libev*.gz; cd $TAR_SOFT/libevent*
./configure --prefix=$INS_SOFT/libevent
make && make install &&cd $TAR_FILE
echo "Libevent is filished........."
#install the memcached........
tar --directory $TAR_SOFT -zxvf memcached*.gz;cd $TAR_SOFT/memcached*
./configure --prefix=$INS_SOFT/memcached --with-libevent=$INS_SOFT
make&&make install&&cd $TAR_FILE
##config
ln -s $INS_SOFT/libevent/lib/libevent-1.3b.so.1 /lib/libevent-1.3b.so.1
#install the memcache......
tar --directory $TAR_SOFT -zxvf memcache*.tgz;cd $TAR_SOFT/memcache-*
$INS_SOFT/php/bin/phpize
./configure --prefix=$INS_SOFT --enable-memcache --with-php-config=$INS_SOFT/php/bin/php-config --with-zlib-dir
make && make install && cd $TAR_FILE
cp /etc/php.ini /tmp/php.ini.bk
sed -i 's/extension_dir = \".\/\"/extension_dir = \"\/usr\/local\/php\/lib\/php\/extensions\/no-debug-non-zts-20060613"/g' /etc/php.ini
echo "extension=memcache.so" >> /etc/php.ini
elif [ "$Memcached" = 2 ];then
echo "#################################################################"
echo "Notice you are deleting the Memcached......"
cd $TAR_SOFT/libevent*
make uninstall&;make clean;rm -Rf $INS_SOFT/libevent*
cd $TAR_SOFT/memcached*
make uninstall;make clean;rm -Rf $INS_SOFT/memcached
cd $TAR_SOFT/memcace-*
make uninstall;make clean;rm -Rf $INS_SOFT/memcache
cd $TAR_FILE
fi
##install the squid......
if [ "$Squid" = 1 ];then
tar --directory $TAR_SOFT -zxvf squid*.gz;cd $TAR_SOFT/squid*
./configure --prefix=$INS_SOFT/squid --enable-delay-pools --enable-snmp --enable-cache-digests --enable-auth-modules="NCSA"
make all&&make install&&cd $TAR_FILE
elif [ "$Squid" = 2 ];then
echo "###########################################################"
echo "Notice you are deleting the Squid......"
cd $TAR_SOFT/squid*
make clean ; make install;rm -Rf $INS_SOFT/squid
cd $TAR_FILE
fi
##Install the SVN.....
if [ "$SVN" = 1 ];then
tar --directory $TAR_SOFT -zxvf subversion*.gz;cd $TAR_SOFT/subversion*
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-apr=/usr/local/apache2 --with-apr-util=/usr/local/apache2 --prefix=/usr/local/svn
make && make install&&cd $TAR_FILE
elif [ "$SVN" = 2 ];then
echo "############################################################"
echo "Notice:you are deleting the SVN......"
cd $TAR_SOFT/subversion*
make clean; rm -Rf $INS_SOFT/svn
fi
echo "##########################################THE END##############################################"
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/26011/showart_409485.html |
|