|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!PS:写剧本的初志,是为了便利本人更无效率的往事情,同时熬炼本人写剧本的才能,固然还但愿可以给人人带来一些小的匡助,但愿人人多多撑持,批评批评,指出不敷的中央。
1、测试情况- [root@hello~]#uname-r2.6.32-279.el6.x86_64[root@hello~]#cat/etc/issueCentOSrelease6.3(Final)Kernelonanm[root@hello~]#dmidecode-ssystem-product-nameVMwareVirtualPlatform
复制代码 2、交互式装置Web办事剧本
注:在编译装置apche之前,必需确保你以后的体系中装置了AdditionalDevelopment、Developmenttools、Base软件包组,个中包括了apache所需的库文件与编译工具,zlib,gcc,automake,pcre等,否则装置大概没法完成。
- [root@helloscripts]#catauto_install_web.sh#!/bin/bash#bloghttp://cfwlxf.blog.51cto.com#createdateof2013-10-30#LoaduserenvironmentvariablePATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbinexportPATH#sourcesystemfunctionslibrary../etc/init.d/functions#definitionsoftwaredownloadandinstalldirectoySOURCE_DIR=/download/source/INSTALL_DIR=/application/#JudgeSOURCE_DIRINSTALL_DIRdirectoyifexits.[!-d${SOURCE_DIR}]&&mkdir${SOURCE_DIR}-p[!-d${INSTALL_DIR}]&&mkdir${INSTALL_DIR}-p&&sleep1&&printf"\033[32mDirectory$SOURCE_DIR$INSTALL_DIRbycreate.\033[0m"#Downloadhttpdsoftwareprintf"\033[33m----------------------------------------------------------------------------|Welcometouseapacheautoinstallscripts|----------------------------------------------------------------------------\033[0m
- "printf"\033[36mDownloadWebServerofsourecepackage,pleaseinputstaringy/n:\033[0m"STRreadSTR#JudgeUserinputofstringifbyyif[$STR="y"]thenprintf"\033[32m----------------------------------------------------------------------------|ApacheSoftwareList|----------------------------------------------------------------------------|1.Downloadwebserversoftwareofhttpd.2.4.4versions.||2.Downloadwebserversoftwareofhttpd.2.2.25versions.||3.Downloadwebserversoftwareofhttpd.2.4.6versions.|----------------------------------------------------------------------------\033[0m
- "read-p"Pleaseyouinputnumber1-4,selecthttpdinstallofhttpdversions:"VERSIONScase"$VERSIONS"in1)cd${SOURCE_DIR}wgethttp://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.4.tar.gz;;2)cd${SOURCE_DIR}wgethttp://mirrors.hust.edu.cn/apache/httpd/httpd-2.2.25.tar.gz;;3)cd${SOURCE_DIR}wgethttp://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.6.tar.gz;;*)sleep1printf"\033[31mError:Pleaseinputnumber1-4,selecthttpdversions.\033[0m
- "exit0esacelsesleep2printf"\033[31mError:Youentertheerrorstring,Pleaseanewinput.\033[0m
- "exit0fi#Uncompresshttpdsoftwarepackagecd${SOURCE_DIR}HTTPD_SOFTWARE=$(find/download/source/-typef|grephttpd|awkBEGIN{FS="/"}END{print$4})tar-xf${HTTPD_SOFTWARE}&&sleep2&&printf"\033[35mUncompresssoftwarebysuccessfully.\033[0m
- "#JudgecurrentdirectoyyesoronuncompresslaterofdirectoryHTTPD_UNCOMPRESS=$(find./-maxdepth1-typed|grephttpd)cd${HTTPD_UNCOMPRESS}RETURN_PWD=$(pwd|cut-d/-f4)ECHO_HTTPD=$(echo${HTTPD_UNCOMPRESS}|awkBEGIN{FS="/"}END{print$2})#Judgewhetherthecurrentdirectoryifuncompressafterofdirectoryif[${RETURN_PWD}=${ECHO_HTTPD}]thensleep1printf"\033[33mIfyouneedsupport--with-included-arp,pleasedownloadsoftwareafterinstall,yes/no:\033[0m"DOWNLOADreadDOWNLOADif["$DOWNLOAD"="yes"]thenwgethttp://mirrors.hust.edu.cn/apache/apr/apr-1.4.6.tar.gzwgethttp://mirrors.hust.edu.cn/apache/apr/apr-util-1.4.1.tar.gz#Judgedownloadaprapr-utilfileofexits.APR_FILE=$(find./-maxdepth1-typef|sed-n/apr-1/p|grep-Po(?<=./).*)APR_UTIL_FILE=$(find./-maxdepth1-typef|sed-n/apr-util/p|grep-Po(?<=./).*)[-e$APR_FIEL$APR_UTIL_FILE]&&sleep2&&printf"\033[35mDownloadFile$APR_FILE,$APR_UTIL_FILEalreadysuccessfully.\033[0m
- "#Uncompressaprapr-utilsoftwarepackage.APACHE_UNCOMPRESS_FILE=$(find/download/source/-maxdepth1-typed|grephttpd)APACHE_UNCOMPRESS_SRCLIB_DIR=${APACHE_UNCOMPRESS_FILE}/srclib/tar-xf$APR_FILE-C$APACHE_UNCOMPRESS_SRCLIB_DIR&&tar-xf$APR_UTIL_FILE-C$APACHE_UNCOMPRESS_SRCLIB_DIR&&cd$APACHE_UNCOMPRESS_SRCLIB_DIRAPR_UNCOMPRESS_FILE=$(find./-maxdepth1-typed|grepapr-1|grep-Po(?<=./).*)APR_UTIL_UNCOMPRESS_FILE=$(find./-maxdepth1-typed|grepapr-util|grep-Po(?<=./).*)mv-f$APR_UNCOMPRESS_FILEapr&&mv-f$APR_UTIL_UNCOMPRESS_FILEapr-util&&sleep2&&action"Uncompressfileapraprutilissuccessfully."true#configureapacheAPACHE_UNCOMPRESS_FILE=$(find/download/source/-maxdepth1-typed|grephttpd)cd$APACHE_UNCOMPRESS_FILE./configure--prefix=/application/${ECHO_HTTPD}--enable-substitute--enable-deflate--enable-expires--enable-ssl--enable-http--enable-rewrite--enable-so--with-mpm=worker--enable-mods-shared=mos--with-z--with-included-aprelse#configureapacheAPACHE_UNCOMPRESS_FILE=$(find/download/source/-maxdepth1-typed|grephttpd)cd$APACHE_UNCOMPRESS_FILE./configure--prefix=/application/${ECHO_HTTPD}--enable-substitute--enable-deflate--enable-expires--enable-ssl--enable-http--enable-rewrite--enable-so--with-mpm=worker--enable-mods-shared=mos--with-zfielseprintf"\033[31mError:Yourcurrentofdirectoryfault$ECHO_HTTPD.\033[0m
- "exit0fi#CompileapachesoftwarepackageRETVAL=0make&&[$?=$RETVAL]&&makeinstallsleep2&&printf"\033[35mApachecompileissuccessfully,pleasestartapacheserverofyes/no:\033[0m"STARTreadSTARTAPACHE_BIN=$(find/application/-maxdepth1-typed|grephttpd)["$START"="yes"]&&${APACHE_BIN}/bin/apachectlstart>/dev/null2>&1#Judgeelinsksottwareofalreadyinstall.SERVER_IP=$(ifconfigeth0|grepinetaddr:|seds/.*r:(.*)B.*$/1/g)ELINKS_RPM=$(rpm-qaelinks|wc-l)[$ELINKS_RPM=1]&&elinks--dumphttp://$SERVER_IP/index.html[$ELINKS_RPM!=1]&&yuminstallelinks&&elinks--dumphttp://$SERVER_IP/index.html
复制代码
#提醒:
剧本实行过程当中,会提醒用户选择apache的版本,若剧本中所供应的版本都不克不及满意公司需求的话,那末你能够把必要的版本链接增加至剧本,略做修正便可。假如对APR不懂得的伴侣,能够点击网址:http://baike.百度.com/link?url=8NJ28ufytnW1h6opu-Z3q3sVaAN82__ePE9okiCUkwsP-WB6ymhYGFmitXL5gUPg3MUaWpTVgglBnAfrRqDAdK具体懂得,剧本大概另有良多不敷的中央,接待人人批评。
3、实例演示
#提醒:
剧本中所供应的apache版本,都已测试经由过程,有需求的运维伴侣们能够依照本人的头脑,略作修正后利用。我以为人人恰好能够借照此剧本,往编写一个LAMP,LNMP情况交互式装置的剧本,大概主动装置的剧本,动下手提拔你写剧本的才能,制止烦琐的操纵,无效率,也能凸起你本人的气力。
本文出自“人生有梦而出色”博客,请务必保存此出处http://cfwlxf.blog.51cto.com/3966339/1321064
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们! |
|