[
root@shell shell]# cat autoLAMP.sh
#!/bin/bash
#auto make install LAMP
#by auto ly 2015
# httpd define path varible
H_FILES=httpd-2.2.31.tar.bz2
H_FILES_DIR=httpd-2.2.31
H_URL=
http://mirrors.cnnic.cn/apache/httpd/H_PREFIX=/usr/local/apache2/
M_FILES=mysql-5.0.41.zip
M_FILES_DIR=mysql-5.0.41
M_URL=
http://gyconfigfc.attogames.com/M_PREFIX=/usr/local/mysql/
# PHP define path variable
P_FILES=php-5.3.28.tar.bz2
P_FILES_DIR=php-5.3.28
P_URL=
http://mirrors.sohu.com/php/P_PREFIX=/usr/local/php5/
if [ -z "$1" ];then
echo -e "\033[36mPlease Select Install Menu follow:\033[0m"
echo -e "\033[32m1)Compile and install Apache server:\033[1m"
echo "2)Compile and install MySQL server"
echo "3)Compile and install PHP server"
echo "4)Configure index.php and start the LAMP service"
echo -e "\033[31mUsage: {$0 1 | 2 | 3 | 4 | help}\033[0m"
exit
fi
if [ $1 -eq 1 ];then
wget -c $H_URL/$H_FILES && tar -jxvf $H_FILES && cd $H_FILES_DIR ;./configure --prefix=$H_PREFIX
if [ $? -eq 0 ];then
make && make install
echo -e "\033[32mThe $H_FILES_DIR Server Install Successfully!\033[0m"
else
echo -e "\033[31mThe $H_FILES_DIR Server Install Failed,Please check ...\033[0m"
fi
fi
# auto install Mysql
if [ $1 -eq 2 ];then
wget -c $M_URL/$M_FILES && unzip $M_FILES && cd $M_FILES_DIR ;chmod +x configure && chmod +x install-sh;./configure --prefix=$M_PREFIX
if [ $? -eq 0 ];then
make && make install
echo -e "\033[32mThe $M_FILES_DIR Server Install Successfully!\033[0m"
else
echo -e "\033[31mThe $M_FILES_DIR Server Install Failed,Please check ...\033[0m"
fi
fi
# auto install PHP Server
if [ $1 -eq 3 ];then
wget -c $P_URL/$P_FILES && tar -jxvf $P_FILES && cd $P_FILES_DIR ;./configure --prefix=$P_PREFIX --with-config-file-path=$P_PREFIX/etc --with-mysql=$M_PREFIX --with-apxs2=/usr/local/apache2/bin/apxs
if [ $? -eq 0 ];then
make && make install
echo -e "\033[32mThe $P_FILES_DIR Server Install Successfully!\033[0m"
else
echo -e "\033[31mThe $P_FILES_DIR Server Install Failed,Please check ...\033[0m"
fi
fi
if [ $1 -eq 4 ];then
sed -i ‘/DirectoryIndex/s/index.html/index.php index.html/g‘ $H_PREFIX/conf/httpd.conf
$H_PREFIX/bin/apachectl restart
echo "AddType application/x-httpd-php .php" >> $H_PREFIX/conf/httpd.conf
IP=`ifconfig eth0|grep "Bcast"|awk ‘{print $2}‘|cut -d: -f2`
echo "You can access http://$IP/"
cat >$H_PREFIX/htdocs/index.php <<EOF
<?php
phpinfo();
?>
EOF
fi