嗨,其实说是脚本,我自己都有些惭愧,竟是整了些重复造轮子,而且代码稳定性欠缺,深深的自责中。。。
好了,先贴出来吧。首先你需要在/root/ 下创建一个 lamp 目录 /root/lamp 将下载到的要安装的压缩包全放进去。
有
libxml2 libmcrypt zlib libpng jpeg freetype autoconf gd httpd mysql php zend phpmyadmin gettext apr apr-util
[root@redhat pub]# cat lamp_install.sh #!/bin/bash #lamp install mkdir /root/lamp cp the libxml2 libcrypt zlib .. to /root/lamp #worning first install gcc yum clean all yum install gcc* -y yum install libtool* -y yum install ncurses-devel -y yum install termcap -y yum install libjpeg-devel -y if [ ! -d "/opt/lamp" ]; then mkdir /opt/lamp fi echo "step 1) : install libxml2 !!!" libx=`find /root/lamp -name libxml2*.tar.gz` echo $libx lib_tar=`tar -zxvf $libx -C /opt/lamp` cd /opt/lamp/libxml2* ./configure --prefix=/usr/local/libxml2 make && make install || echo "NO zuo NO Die!!!" echo "########################" echo " libxml2 install ok " echo "step 2) : install libmcrypt !!!" libmc=`find /root/lamp -name libmcrypt*.tar.gz` echo $libmc libmc_tar=`tar -xzvf $libmc -C /opt/lamp` cd /opt/lamp/libmcrypt* ./configure --prefix=/usr/local/libmcrypt make && make install || echo "gun cu!!!" echo "############################" echo " libmcrypt install ok" echo "step 3) : install zlib" zli=`find /root/lamp -name zlib*.tar.gz` echo $zli zli_tar=`tar -xzvf $zli -C /opt/lamp` cd /opt/lamp/zlib* ./configure cat Makefile | sed -i '/^CFLAGS=-O3/s/$/ -fPIC/p' Makefile make && make install || echo "pen dan" echo "#############################" echo " zlib install ok" echo "step 4) : install libpng" libp=`find /root/lamp -name libpng*.tar.gz` echo $libp libp_tar=`tar -xzvf $libp -C /opt/lamp` cd /opt/lamp/libpng* ./configure --prefix=/usr/local/libpng make && make install || echo "so do s nei !!!" echo "################################" echo " libpng install ok" echo "step 5) : install jpeg" mkdir /usr/local/jpeg6 mkdir /usr/local/jpeg6/bin mkdir /usr/local/jpeg6/lib mkdir /usr/local/jpeg6/include mkdir -p /usr/local/jpeg6/man/man1 jpeg=`find /root/lamp -name jpeg*.tar.gz` echo $jpeg jpeg_tar=`tar -xzvf $jpeg -C /opt/lamp` cd /opt/lamp/jpeg* ./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static make && make install || echo "so cool !!!" echo "################################" echo " jpeg install ok" echo "step 6) : install freetype" free=`find /root/lamp/ -name free*.tar.gz` echo $free free_tar=`tar -xzvf $free -C /opt/lamp` cd /opt/lamp/free* ./configure --prefix=/usr/local/freetype make && make install || echo " hahahah !!!" echo "################################" echo " jpeg install ok" echo "step 7) : install autoconf" auto=`find /root/lamp -name auto*.tar.gz` echo $auto auto_tar=`tar -xzvf $auto -C /opt/lamp` cd /opt/lamp/auto* ./configure make && make install || echo "everyone is no.1 !!!" echo "###############################" echo " autoconf install ok" echo "step 8) : install gd" #first install the gettext gett=`find /root/lamp -name gettext*.tar.gz` gett_tar=`tar -xzvf $gett -C /opt/lamp` cd /opt/lamp/gettex* ./configure --enable-m4_pattern_allow make && make install || echo "sha bi le ba !!!" gd=`find /root/lamp -name gd*.tar.gz` echo $gd gd_tar=`tar -xzvf $gd -C /opt/lamp` cd /opt/lamp/gd* ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-freetype=/usr/local/freetype --enable-m4_pattern_allow make && make install || echo "ya ya ya !!!" echo "#################################" echo " gd install ok " echo "step 9) : install httpd" apr=`find /root/lamp -name apr-1*.tar.gz` echo $apr apr_tar=`tar -xzvf $apr -C /opt/lamp` cd /opt/lamp/apr* ./configure --prefix=/usr/local/apr make && make install || "ni cai a !!!" apru=`find /root/lamp -name apr-ut*.tar.gz` echo $apru apru_tar=`tar -xzvf $apru -C /opt/lamp` cd /opt/lamp/apr-u* ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ make && make install || echo "ni la ala" htt=`find /root/lamp -name http*.tar.gz` echo $htt htt_tar=`tar -xzvf $htt -C /opt/lamp` cd /opt/lamp/htt* ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd/ --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support make && make install || echo "ni shi shi !!!" /usr/local/apache2/bin/apachectl start echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local echo "###################################" echo " httpd install ok" echo "step 10) : install mysql" groupadd mysql useradd -g mysql mysql myFile=`find /root/lamp -name mysql*.tar.gz` echo $myFile my_tar=`tar -zxvf $myFile -C /opt/lamp` if [ $? -eq 0 ] then cd /opt/lamp/mysql* echo "%%%%%%%%%%%%%%%%%%%%%%%%%%" ./configure --prefix=/usr/local/mysql --with-extra-charsets=all make && make install || echo "$$$$$$$$$$$$$$$$$$$$$$$$$$$" else echo 'tar erro please check !!!' exit 1 fi cp support-files/my-medium.cnf /etc/my.cnf /usr/local/mysql/bin/mysql_install_db --user=mysql chown -R root /usr/local/mysql chown -R mysql /usr/local/mysql/var chgrp -R mysql /usr/local/mysql #/usr/local/mysql/bin/mysqld_safe --user=mysql #inset password default root /usr/local/mysql/bin/mysqladmin -uroot password root #startup mechine start mysql echo "/usr/local/mysql/share/mysql/mysql.server start" >> /etc/rc.d/rc.local echo "step 11) : install php" php=`find /root/lamp -name php-*.tar.gz` echo $php php_tar=`tar -xzvf $php -C /opt/lamp` cd /opt/lamp/php-* ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets make && make install || echo "bu guan bu guan !!!" cp php.ini-dist /usr/local/php/etc/php.ini add apache conf file to execute php AddType application/x-httpd-php .php .phtml echo "AddType application/x-httpd-php .php .phtml" >> /etc/httpd/httpd.conf /usr/local/apache2/bin/apachectl restart echo "step 12) install zend" zend=`find /root/lamp -name Zend*` echo $zend tar_zend=`tar -zxvf $zend -C /opt/lamp` cd /opt/lamp/Zend* ./install.sh echo "step 13) install phpMyadmin" phpmd=`find /root/lamp -name phpMyAdmin*.tar.gz` echo $phpmd pmd_tar=`tar -xzvf $phpmd -C /opt/lamp` cp -a /opt/lamp/phpMy* /usr/local/apache2/htdocs/phpmyadmin cd /usr/local/apache*/htdocs/phpmyadmin cp config.sample.inc.php config.inc.php #vi the config.inc.php change auth_type to http