Chinaunix首页 | 论坛 | 博客
  • 博客访问: 230748
  • 博文数量: 57
  • 博客积分: 955
  • 博客等级: 准尉
  • 技术积分: 587
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-14 13:30
文章分类

全部博文(57)

文章存档

2012年(2)

2011年(55)

分类: LINUX

2011-05-23 13:34:14

----LAMP自动部署脚本,就是把命令打到脚本里,--擦了个擦,呵呵
#!/bin/bash
#written by booduklee
#2011-05-16
#this scripts is used to create lamp automated
export PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
export src=/usr/local/src
export default=/usr/local
export repo=/etc/yum.repos.d
export m_daemon=/etc/init.d
export man=/usr/share/man
#create the baserepo to install the software
mkdir -pv /root/repo.bak;
find $repo -name "*.repo" -exec mv {} /root/repo.bak \;
cat >> $repo/server.repo << EOF
[base]
name=base
baseurl=file:///mnt/Server
enable=1
gpgcheck=0
EOF
if mount | grep hdc;
then
echo "the cd-rom has been mounted";
yum clean all;
yum install gcc gcc-c++;
else
mount /dev/hdc /mnt;
yum clean all;
yum install gcc gcc-c++;
fi

#  update pid
if [ -f /tmp/lamp.pid ];
then
echo "the scripts has runned by others";
exit 4;
else
echo $$ > /tmp/lamp.pid;
fi

# make apache

cd $src;
tar jxvf httpd-2.2.11.tar.bz2; 
cd  httpd-2.2.11;
./configure --prefix=/usr/local/apache --enable-so --enable-mods-shared=most --disable-usedir --with-mpm=prefork;
make && make install;
cat >> $m_daemon/apache << EOF
#!/bin/bash
#written by booduklee
#this scripts is used to star|stop|restart httpd
APACHE=/usr/local/apache/bin/apachect1
case $1 in
start)
   $APACHE -k start && echo "start ok" || echo "start error";
   ;;
stop)
   $APACHE -k stop && echo "stop ok" || echo "stop error";
   ;;
restart)
    $APACHE -k restart && echo "restart ok" || echo "restart error";
    ;;
*)
     echo " usage start | restart | stop";
esac
EOF

#----------make mysql-----------------------

software=$default/mysql;
export mysql=mysql-5.5.3-m3;
yum install  ncurses-devel libtool libtool-ltdl libtool-ltdl-devel;
cd $src;
tar zxvf $mysql.tar.gz;
cd $mysql;
./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-table --with-embedded-server --enable-local-infile --with-plugins=innobase --enable-static --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static;
make && make install;
if grep '^mysql' /etc/passwd;
then
echo "the user mysql has exists";
else
groupadd mysql;
useradd -g mysql mysql;
fi
chown mysql.mysql $software;
cat >> /etc/ld.so.conf << EOF
$software/lib/mysql
EOF
cp $src/$mysql/support-files/my-huge.cnf /etc/my.cnf;
sed -i '/\[mysqld\]/a datadir  = /usr/local/mysql/data' /etc/my.cnf;
sed -i 's/^thread_concurrency/#&/' /etc/my.cnf;
mkdir -pv $software/data;
chown mysql.mysql $software/data;
$software/bin/mysql_install_db --user=mysql;
cp $software/share/mysql/mysql.server $m_daemon/mysql.server;
ln -s $software/bin/* $default/bin/;
ln -s $software/libexec/* $default/libexec/;
ln -s $software/share/man/man1/*  $man/man1/;
ln -s $software/share/man/man8/* $man/man8/;
unset software

#------------make php ----------------------

cd $src;
tar zxvf libiconv*.tar.gz;
cd libiconv-1.13.1;
./configure --prefix=/usr/local;
make && make install;
cd $src;
tar zxvf libmcrypt-2.5.8.tar.gz;
cd libmcrypt-2.5.8;
./configure && make && make install;
cd $src;
tar zxvf mhash*.tar.gz;
cd mhash-0.9.9.9;
./configure && make && make install;
ln -s $default/lib/* /usr/lib;
cd $src;
tar zxvf mcrypt-2.6.8.tar.gz;
cd mcrypt-2.6.8;
ldconfig;
./configure;
make && make install;
yum install libxml2-devel curl-devel libpng-devel freetype-devel libjpeg-devel
-y;
cd $src;
tar zxvf php-5.2.14.tar.gz;
cd php5.2.14;
sh /root/php.sh;
make ZEND-EXTRA-LIBS='-liconv';
make install;
/etc/init.d/mysql.server start;

#--------------the major make install-------------------
#echo "it's start to install lamp";
#m_apache && $m_daemon/apache start;
#m_mysql && $m_daemon/mysql.server start;
#m_php ;
#rm -rf $repo/server.repo;
find /root/repo.bak -name "*.repo" -exec mv {} $repo \;
rm -rf /tmp/lamp.pid;
exit 




阅读(1450) | 评论(2) | 转发(0) |
0

上一篇:喝酒有点难受

下一篇:find 详解

给主人留下些什么吧!~~

booduklee2011-05-25 08:25:02

yifangyou: 楼主的lamp是代码编译的,应该在一台机器上都安装到同一个目录,把目录打成tar包,分别考到别的机器上,解压就可以使用,根本不需要每一台都安装啊.....
这个脚本不是用来做大批量部署安装的,----如果大批量部署我觉得只编译一个然后封装成rpm包拿过去装就行了,一台机器编译的时候不是太慢了嘛,不想等,所以---就把命令都敲进去,呵呵,---

yifangyou2011-05-24 20:43:55

楼主的lamp是代码编译的,应该在一台机器上都安装到同一个目录,把目录打成tar包,分别考到别的机器上,解压就可以使用,根本不需要每一台都安装啊