Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1155897
  • 博文数量: 150
  • 博客积分: 2739
  • 博客等级: 少校
  • 技术积分: 2392
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-07 12:28
文章分类

全部博文(150)

文章存档

2015年(2)

2014年(16)

2013年(10)

2012年(58)

2011年(64)

分类: Python/Ruby

2011-09-27 14:53:44

这个是一键安装LAMP,但是需要将软件下载好然后运行
#!/bin/bash
read -p "Please enter the LAMP platform package building the full path!!For example:"/root/":" LJ
cd $LJ
if [ -z ${LJ##*/} ] ; then
read -p "Please select the LAMP platform built the way,the compiler Installation Please enter a number "1"!!RPM installation Please enter the number "2"!!Enter:" IW
if [ $IW = 1 ] ; then
echo "Construction of LAMP platform you choose to compile and install the way!!"
ASF=`ls $LJ | grep httpd*`
echo $AFS
MSF=`ls $LJ | grep mysqld*`
PHPF=`ls $LJ | grep php*`
ASD=${ASF%.tar*}
MSD=${MSF%.tar*}
PHPD=${PHPF%.tar*}
cd $LJ
for LAMP in $ASF $MSF $PHPF
do
cd $LJ
case "$LAMP" in
*.tar.gz)
tar zxvf $LAMP -C /usr/src
;;
*.tar.bz2)
tar jxvf $LAMP -C /usr/src
;;
*)
echo "Error!!$LAMP is not tar files!!"
break
esac
case "$LAMP" in
*$ASD*)
cd /usr/src/$ASD/ &&
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-cgi --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/usr/local/apache2/htdocs && make && make install
if [ $? != 0 ] ; then
echo "Apache server installation failed!!"
break
else
echo "Congratulations!!!Apache server installation was successful!!!"
fi
;;
*$MSD*)
useradd -M -s /sbin/nologin mysql
cd /usr/src/$MSD/ &&
./configure --prefix=/usr/local/mysql && make && make install
if [ $? != 0 ] ; then
echo "MySQL server installation failed!!!"
break
else
echo "Congratulations!!!MySWL server installation was successful!!!"
fi
;;
*)
cd /usr/src/$PHPD/ &&
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --enable-sockets --enable-mbstring && make && make install
if [ $? != 0 ] ; then
echo "PHP installation failed!!!"
break
else
echo "Congratulations!!!PHP installation was successful!!!"
fi
echo "LAMP platform installation is complete"
if [ $? = 0 ] ; then
cp -f /usr/src/$MSD/support-files/my-medium.cnf /etc/my.cnf && 
/usr/local/mysql/bin/mysql_install_db --user=mysql && 
chown -R root.mysql /usr/local/mysql && 
chown -R mysql /usr/local/mysql/var &&
echo "/usr/local/mysql/lib/mysql/" >> /etc/ld.so.conf &&
ldconfig &&
cp /usr/src/$MSD/support-files/mysql.server /etc/init.d/mysqld &&
chmod a+x /etc/init.d/mysqld &&
chkconfig --add mysqld &&
chkconfig mysqld on &&
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/apache2/bin &&
echo "PATH=$PATH:/usr/local/mysql/bin:/usr/local/apache2/bin" >> /etc/profile &&
killall httpd &&
cd $LJ
cp -rf http.conf /usr/local/apache2/conf/httpd.conf
cp -rf test.php  /usr/local/apache2/htdocs/
rpm -e httpd --nodeps &&
cp /usr/src/$PHPD/php.ini-dist /usr/local/php5/php.ini 
if [ $? != 0 ] ; then
echo "LAMP  platform for automatic configuration error,configuration terminated!!!"
break
else
/usr/local/apache2/bin/apachectl  start
cd $LJ
echo "LAMP platform for successful auto-configuration!!!"
fi
fi
esac
done
elif [ $IW = 2 ] ; then
echo "Construction of your choice LAMP platform approach is RPM installation!!!"
read -p "Do you install the Httpd server now?If so,please enter "yes"!!Enter:" HTTPD
read -p "Do you install the MySQL server now?If so,please enter "yes"!!Enter:" MYSQL
read -p "Do you install the PHP now?If so,please enter "yes"!!Enter:" PHP
if [ $HTTPD = yes ] ; then
ls -l $LJ | awk '{print $7}' | grep -i "^httpd-2" > /tmp/rpm
if [ $? != 0 ] ; then
echo "Find Apache server rpm package failed!!"
exit 0
fi
rpm -Uvh $LJ`cat /tmp/rpm` &> /tmp/tmp
if [ $? != 0 ] ; then
grep -v "`grep installed /tmp/tmp | awk '{print $2}'`" /tmp/rpm > /tmp/rpm2
if [ ! -z "`cat /tmp/rpm2`" ] ; then
rpm -Uvh $LJ`cat /tmp/rpm2`
if [ $? != 0 ] ; then
echo "Installing HTTPD service failed!!There may be unresolved dependencies!!!"
else
echo "HTTPD service installed successfully!!!"
fi
else
echo "HTTPD service already installed before!!!"
fi
else
echo "HTTPD service installed successfully!!!"
fi
fi
if [ $MYSQL = yes ] ; then
ls -l $LJ | awk '{print $7}' | grep -i "^mysql-5" > /tmp/rpm && ls -l $LJ | awk '{print $7}' | grep -i "^mysql-server" >> /tmp/rpm && ls -l $LJ | awk '{print $7}' | grep -i "^mysql-connector" >> /tmp/rpm && ls -l $LJ | awk '{print $7}' | grep -i "^mysql-connector-odbc" >> /tmp/rpm && ls -l $LJ | awk '{print $7}' | grep -i "^perl-DBI" >> /tmp/rpm && ls -l $LJ | awk '{print $7}' | grep -i "^perl-DBD-MySQL" >> /tmp/rpm && ls -l $LJ | awk '{print $7}' | grep -i "^libtool-ltdl-1" >> /tmp/rpm && ls -l $LJ | awk '{print $7}' | grep -i "^unixODBC-2" >> /tmp/rpm
if [ $? != 0 ] ; then
echo "Find MySQL server rpm package failed!!"
break
fi
rpm -Uvh $LJ`cat /tmp/rpm` &> /tmp/tmp
if [ $? != 0 ] ; then
grep -v "`grep installed /tmp/tmp | awk '{print $2}'`" /tmp/rpm > /tmp/rpm2
if [ ! -z "`cat /tmp/rpm2`" ] ; then
rpm -Uvh $LJ`cat /tmp/rpm2`
if [ $? != 0 ] ; then
echo "Installing MySQL service failed!!there may be unresolved dependencies!!"
else
echo "MySQL service installed successfully!!"
fi
else
echo "MySQL Service already installed before!!"
fi
else
echo "MySQL service installed successfully!!"
fi
fi
if [ $PHP = yes ] ; then
ls -l $LJ | awk '{print $7}' | grep -i "^php-5" > /tmp/rpm && ls -l $LJ | awk '{print $7}' | grep -i "^php-mysql" >> /tmp/rpm && ls -l $LJ | awk '{print $7}' | grep -i "^php-common" >> /tmp/rpm && ls -l $LJ | awk '{print $7}' | grep -i "^php-pdo" >> /tmp/rpm 
if [ $? != 0 ] ; then
echo "Find PHP rpm package failed!!"
fi
rpm -Uvh $LJ`cat /tmp/rpm` &> /tmp/tmp
if [ $? != 0 ] ; then
grep -v "`grep installed /tmp/tmp | awk '{print $2}'`" /tmp/rpm > /tmp/rpm2
if [ ! -z "`cat /tmp/rpm2`" ] ; then
rpm -Uvh $LJ`cat /tmp/rpm2`
if [ $? != 0 ] ; then
echo "Installing PHP failed!!there may be unresolved dependencies!!"
else
echo "PHP installed successfully!!"
fi
else
echo "PHP already installed before!!"
fi
else
echo "PHP installed successfully!!"
fi
fi
else
echo "Error!!Which means you do not choose to build LAMP platform!!"
fi
else
echo "Error!!You did not enter the full path LAMP package!!"
fi
cd ~

阅读(1021) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

2011-09-28 19:51:25

http://www.bags2world.com/