今天教大家怎么配置http服务器的apache平台
虽然nginx很火,很多人喜欢用nginx,但是还是有些会用apache来放网站。
今天教大家怎么配置的apache平台。
1、下载APACHE源代码wgethttp:ftp。cuhk。edu。hkpubpackagesapache。orghttpdhttpd2。4。38。tar。gz
安装相关库yuminstallzlibzlibdevelapraprutilpcrey
解压、安装tarzxvfhttpd2。4。38。tar。gzcdhttpd2。4。38
开始安装
。configureprefixusrlocalapache2。4。38enabledeflateenableexpiresenableheadersenablemodulesmostenablesowithmpmworkerenablerewritewithaprusrlocalaprwithaprutilusrlocalaprutilwithpcreusrlocalpcre
编译参数说明:
1。prefixusrlocalapache2。4。38指定安装路径为
2。enabledeflate提供对内容的压缩传输编码支持
3。enableexpires允许通过配置文件控制http的expires和cahecontrol
4。enableheaders提供允许对HTTP请求头的控制
5。withmpmworker选择apachempm的模式为worker模式
6。enablerewrite提供基于URL规则的重写功能
7。enableso激活APACHE服务的DSO(全称dynamicsharedobject,动态共享对象
上面如果没有安装zlibdevel包,这步编译时会报如下错误:
checkingforzliblocation。。。notfound
checkingwhethertoenablemoddeflate。。。configure:error:moddeflatehasbeenrequestedbutcannotbebuiltduetoprerequisitefailures
上面编译无误后执行下面的命令开始安装:
编译Apache出现的问题:configure:error:APRnotfound
今天编译apache时出错:
。configureprefix检查编辑环境时出现:
checkingforAPR。。。no
configure:error:APRnotfound。Pleasereadthedocumentation
解决办法:
方法一:
安装httpd的软件依赖包yuminstallyaprdevelaprutildevelopenssldevellibeventdevelpcredevel
方法二源码安装
1。下载所需软件包:wgethttp:archive。apache。orgdistaprapr1。4。5。tar。gzwgethttp:archive。apache。orgdistapraprutil1。3。12。tar。gzwgethttp:jaist。dl。sourceforge。netprojectpcrepcre8。10pcre8。10。zip
2。卸载系统自带的apryumremoveapr
a:解决aprnotfound的问题tarzxfapr1。4。5。tar。gzcdapr1。4。5。configureprefixusrlocalaprmakemakeinstal
b:解决APRutilnotfound问题tarzxfaprutil1。3。12。tar。gzcdaprutil1。3。12。configureprefixusrlocalaprutilwithaprusrlocalaprmakemakeinstall
c:解决pcre问题unzipopcre8。10。zipcdpcre8。10。configureprefixusrlocalpcremakemakeinstall
这一步可能会出现pcre编译失败,libtool:line990:g:commandnotfound错误只要yumyinstallgccgccc即可解决问题
4。最后编译Apache时加上:withaprusrlocalaprwithaprutilusrlocalaprutilwithpcreusrlocalpcre
2、最后,成功编译完成,安装makemakeinstall
3、创建软链接lnsapache2。2。31apache
4、启动APACHE并测试
usrlocalapachebinapachectlstart
5、安装php支持apache,编译php文件(详细安装请看我另外一篇:完美运行centos7上的PHP服务器配置)
安装配置。configureprefixusrlocalphpwithapxs2usrlocalapachebinapxswithconfigfilepathusrlocalphpetcenableinlineoptimizationdisabledebugdisablerpathenablesharedenableopcacheenablefpmwithfpmuserwwwwithfpmgroupwwwwithmysqlmysqlndwithmysqlimysqlndwithpdomysqlmysqlndwithgettextenablembstringwithiconvwithmcryptwithmhashwithopensslenablebcmathenablesoapwithlibxmldirenablepcntlenableshmopenablesysvmsgenablesysvsemenablesysvshmenablesocketswithcurlwithzlibenablezip
6、修改apache配置文件
httpd。conf
1、在LoadModule后面添加:LoadModulephp5modulemoduleslibphp5。so
备注:不添加则访问。php文件将会变成下载
2、在DirectoryIndex后面添加:index。php
3、在AddTypeapplicationxgzip。gz。tgz后面添加:AddTypeapplicationxhttpdphp。php。php前面有一个空格
注意:源码安装的时候必须加上这个(withapxs2usrlocalapache24binapxs),它的作用就是生成libphp5。so。