环境:centos6.6;httpd-2.2.34;MysqL-5.5.55;PHP5.6.31
#!/bin/bash #2017-08-12 #authorbyTanWenXin #AutoinstallLAMP #createDNSserver cat>>/etc/resolv.conf<<EOF nameserver192.168.8.2 EOF ######################httpd-2.2.34install######################### functioninstall_httpd(){ #init yuminstall-ygccgcc-c++libxml2libxml2-devellibmcryptlibmcrypt-develmhashmhash-develbzip2bzip2-devellibjpeg-devellibpng-develfreetype-developenssl-devellibcurl-devellibmcrypt-devel>/dev/null mkdir/download&&cd/download wgethttp://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.2.34.tar.gz tarzxfhttpd-2.2.34.tar.gz&&cdhttpd-2.2.34&&./configureprefix=/usr/local/apache2-enable-rewrite--enable-so--enable-cgi--enable-modules=most--enable-mpms-shared=all if[$?-eq0];then make&&makeinstall echo"apacheinstallsuccessful!!!!!" else echo"apacheinstallFailed" exit2 fi ## #cp/usr/local/apache2/bin/apachectl/etc/init.d/httpd echo"/usr/local/apache2/bin/apachectlstart">>/etc/rc.local ## cp/usr/local/apache2/conf/httpd.conf/usr/local/apache2/conf/httpd.conf.bck sed-i's#index.html#index.htmlindex.PHP#g'/usr/local/apache2/conf/httpd.conf sed-i-e'/Groupdaemon/a\ServerNamelocalhost'/usr/local/apache2/conf/httpd.conf cat>>/usr/local/apache2/htdocs/index.PHP<<EOF <?PHP PHPinfo(); ?> EOF cat>>/usr/local/apache2/conf/httpd.conf<<EOF AddTypeapplication/x-httpd-PHP.PHP #AddTypeapplication/x-httpd-PHP-source.PHPs EOF } ###############MysqL-5.5.55install################################ functioninstall_MysqL(){ #installMysqL cd/download wgethttp://mirrors.sohu.com/MysqL/MysqL-5.5/MysqL-5.5.55-linux2.6-x86_64.tar.gz tarxfMysqL-5.5.55-linux2.6-x86_64.tar.gz-C/usr/local cd/usr/local ln-sMysqL-5.5.55-linux2.6-x86_64/MysqL ln-s/usr/local/MysqL/bin/*/usr/bin ##adduserMysqL grep"\bMysqL\b"/etc/passwd if[$?-ne0];then useradd-rMysqL-s/sbin/nologin-M fi #createmy.cnf mkdir-p/mydata/data chown-RMysqL.MysqL/mydata/data chown-RMysqL.MysqL/usr/local/MysqL/* cd/usr/local/MysqL/support-files \cpmy-large.cnf/etc/my.cnf ##modifymy.cnf sed-i"s#thread_concurrency=8#thread_concurrency=4#g"/etc/my.cnf sed-i-e'/log-bin=MysqL-bin/a\datadir=/mydata/data'/etc/my.cnf #createstartscript cpMysqL.server/etc/rc.d/init.d/MysqLd chkconfig--addMysqLd #initandstartMysqL cd/usr/local/MysqL scripts/MysqL_install_db--user=MysqL--datadir=/mydata/data/ /etc/init.d/MysqLdstart } ############################PHP5.6.31install###################### functioninstall_PHP(){ cd/download wgethttp://hk1.PHP.net/get/PHP-5.5.38.tar.gz/from/this/mirror tarzxfmirror&&cdPHP-5.5.38&&./configure--prefix=/usr/local/PHP--with-MysqL=MysqLnd--with-MysqLi=MysqLnd--with-pdo-MysqL=MysqLnd--enable-sockets--with-apxs2=/usr/local/apache2/bin/apxs if[$?-eq0];then make-j4&&makeinstall echo"LAMPinstallsuccessful!!!!!" else echo"PHPinstallFailed" exit2 fi \cpPHP.ini-production/etc/PHP.ini /usr/local/apache2/bin/apachectlstart } ##########################main###################### read-p"AreyousureinstallLAMPviasourcecode?(yesorno)"READ case$READin yes|YES|Yes) install_httpd install_MysqL install_PHP ;; no|NO|No) echo"Sinceyoudon'twanttoinstallLAMP,thescritpexit" exit5 ;; *) echo"Pleasechoose"yes"or"no"again:" read-p"AreyousureinstallLAMPviasourcecode?(yesorno)"READ esac原文链接:https://www.f2er.com/bash/391473.html