#!/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