很久以前修改的一个脚本,用于一键安装LAMP环境。

#!/bin/bash
#Date:2010.12.20
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear
echo ""
echo -e "33[7m"
echo "+----------------------------------------+"
echo "+ +"
echo "+ LAMP一键安装脚本 +"
echo "+ Author: Panzhongy.pt@Taobao.com +"
echo "+ Platform: Linux +"
echo "+ 2010-12-15 +"
echo "+----------------------------------------+"
echo -e "33[0m"
www="/home/wwwroot"
user="root"
pass="123456"
install_base()
{
echo "+--------------------------------------+"
echo "+ install apache+mysql+phpmyadmin +"
echo "+--------------------------------------+"
yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql
yum -y install pango-devel mod_ssl php-gd php-snmp php-pear php-ldap
yum -y install net-snmp net-snmp-devel net-snmp-utils net-snmp-libs net-snmp-utils net-snmp-perl libart_lgpl ntp
ckconfig httpd on
chkconfig mysqld on
mkdir $www
cp -R conf/vhost.conf /etc/httpd/conf/
sed -i -e "s#@www@#$www#g" /etc/httpd/conf/vhost.conf
echo "Include /etc/httpd/conf/vhost.conf">> /etc/httpd/conf/httpd.conf
sed -i -e \'s/AddDefaultCharset UTF-8/#AddDefaultCharset UTF-8/g\' /etc/httpd/conf/httpd.conf
service httpd restart
service mysqld restart
mysqladmin -u root password $pass
}
init()
{
echo ""
echo "Please input HTTP path:"
read -p "(Default: $www):" temp
if [ "$temp" != "" ]; then
www=$temp
fi
echo ""
echo "Please input MySQL username:"
read -p "(Default: $user):" temp
if [ "$temp" != "" ]; then
user=$temp
fi
echo ""
echo "Please input MySQL password:"
read -p "(Default: $pass):" temp
if [ "$temp" != "" ]; then
pass=$temp
fi
}
init
install_base