if rpm -q gcc gcc-c++ perl make automake lrzsz
then
echo "已有开发环境。" >>/aaa
else
echo "没有开发环境,现在安装。" >>/aaa
yum -y install gcc gcc-c++ perl make automake lrzsz
fi
#以上是检测开发环境。
cd /lamp
for tar in `ls /lamp`
do
case $tar in
#当变量值是以.tar.gz结尾的时候所要执行的命令序列。
*.tar.gz)
tar zxf $tar -C /usr/src
;;
#当变量值是以.tar.bz2结尾的时候所要执行的命令序列。
*.tar.bz2)
tar jxf $tar -C /usr/src
;;
#当变量值是以.zip结尾的时候所要执行的命令序列。
*.zip)
unzip -d /usr/src $tar
;;
*)
echo "$tar不是压缩文件!"
;;
esac
done
echo '解压完毕!!!' >>/aaa
#以上是解压所需的源码包。
if rpm -q httpd
then
rpm -e httpd --nodeps &&echo "已卸载rpm安装的apache" >>/aaa
cd /usr/src/http*
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi &&make&&make install
else
cd /usr/src/http*
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi &&make&&make install
fi
if [ -d /usr/local/httpd ];then
echo "Apache已经编译安装完毕!接下来优化配置Apache。" >>/aaa
cd /usr/local/httpd
ln -s /usr/local/httpd/bin/* /usr/local/bin
\\cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
sed -i '1a#chkconfig: 35 25 15 \\#description:zhis is apache' /etc/init.d/httpd
chkconfig --add httpd &&chkconfig httpd on
sed -i '$aAddType application/x-httpd-php .php' /usr/local/httpd/conf/httpd.conf
sed -i '$aadddefaultcharset UTF-8' /usr/local/httpd/conf/httpd.conf
fi
#以上是安装及优化Apache。
/etc/init.d/httpd start
if netstat -lntup|grep 80
then
echo "APACHE已经成功启动!!!" >>/aaa
fi
#以上是启动Apache。
if cd /usr/src/cmak*
then
./configure &&make&&make install
fi
#以上是安装cmake工具。
if rpm -q mysql mysql-server
then
echo "rpm包的mysql已安装,下一步卸载。" >>/aaa
rpm -e mysql mysql-server --nodeps &&echo "rpm安装的mysql已卸载完毕!" >>/aaa
fi
if rpm -q ncurses-devel
then
echo "mysql的依赖软件包已安装" >>/aaa
else
yum install ncurses-devel -y
fi
sql=/usr/src/mysql*
sq=/usr/local/mysql
if cd $sql
then
cmake -DCMAKE_INSTALL_PREFIX=$sq -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all &&make&&make install
else
echo "没有mysql源码文件" >>/aaa
fi
#以上是安装mysql。
userdel -r mysql
useradd -M -s /sbin/nologin mysql
if [ -d $sq ];then
chown -R mysql:mysql $sq
\\cp $sq/support-files/my-medium.cnf /etc/my.cnf
\\cp $sq/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
ln -s /usr/local/mysql/bin/* /usr/local/bin/
fi
if grep OK /mysql.txt
then
echo "初始化数据库成功!!!" >>/aaa
/etc/init.d/mysqld start && echo "mysql启动成功!!!" >>/aaa
else
echo "初始化数据库失败!!!" >>/aaa
fi
if rpm -q zlib-devel&&rpm -q libxml2-devel
then
echo "php依赖软件已安装!" >>/aaa
else
yum install zlib-devel libxml2-devel perl -y
fi
if cd /usr/src/libmcrypt*
then
./configure&&make&&make install &&echo "libmcrypt已经安装好" >>/aaa
fi
if cd /usr/src/mhash*
then
./configure&&make&&make install &&echo "mhash已经安装好"
fi
if cd /usr/src/mcrypt*
then
echo "/usr/local/lib" >>/etc/ld.so.conf && ldconfig
./configure&&make&&make install
else
echo "加密工具源码包不存在" >>/aaa
fi
php1=/usr/src/php-*
if cd $php1
then
./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring &&make&&make install
else
echo "php源码包不存在!!!" >>/aaa
fi
if [ -d /usr/local/php5 ];then
echo "php已经安装完毕" >>/aaa
\\cp /usr/src/php-*/php.ini-development /usr/local/php5/php.ini
sed -i '1,$s/short_open_tag = Off/short_open_tag = On/g' /usr/local/php5/php.ini
/etc/init.d/httpd stop
/etc/init.d/httpd start
else
echo "php没安装成功!!!" >>/aaa
fi
if cd /usr/src/ZendGuard*
then
\\cp /usr/src/ZendGuard*/php-*/ZendGuard* /usr/local/php5/lib/php
sed -i '$azend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so' /usr/local/php5/php.ini
sed -i '$azend_loader.enable=1' /usr/local/php5/php.ini
echo 'php优化成功!' >>/aaa
fi
if cd /usr/src/phpMyAdmin-*
then
mv /usr/src/phpMyAdmin-* /usr/local/httpd/htdocs/phpMyAdmin && mv /usr/local/httpd/htdocs/phpMyAdmin/config.sam* /usr/local/httpd/htdocs/phpMyAdmin/config.inc.php
echo "phpMyAdmin部署成功"
else
echo "部署phpMyAdmin失败" >>/aaa
fi