一、环境的搭建
实验环境:
操作系统:Centos 7.4
[root@xuegod70 ~]# lsapr-1.6.3.tar.gz ?apr-util-1.6.1.tar.bz2 ?httpd-2.4.33.tar.gz ?pcre-8.41.tar.gz ?#主要的按照包,下面是具体的安装操作[root@xuegod70 ~]# yum install -y bzip2[root@xuegod70 ~]# tar xf apr-1.6.3.tar.gz [root@xuegod70 ~]# lsapr-1.6.3 ?apr-1.6.3.tar.gz ?apr-util-1.6.1.tar.bz2 ?httpd-2.4.33.tar.gz ?pcre-8.41.tar.gz[root@xuegod70 ~]# cd apr-1.6.3[root@xuegod70 apr-1.6.3]# yum install -y gcc gcc-c++ ????#安装依赖包[root@xuegod70 apr-1.6.3]# ./configure --prefix=/usr/local/apr[root@xuegod70 apr-1.6.3]# make && make install[root@xuegod70 ~]# tar xf apr-util-1.6.1.tar.bz2 [root@xuegod70 ~]# cd apr-util-1.6.1[root@xuegod70 apr-util-1.6.1]# ./configure [root@xuegod70 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config [root@xuegod70 apr-util-1.6.1]# yum install expat-devel -y ?#安装依赖包[root@xuegod70 apr-util-1.6.1]# make && make install[root@xuegod70 ~]# tar xf pcre-8.41.tar.gz [root@xuegod70 ~]# cd pcre-8.41[root@xuegod70 pcre-8.41]# ./configure --prefix=/usr/local/pcre[root@xuegod70 pcre-8.41]# make && make install
二、隐藏Apache版本信息
1. 屏蔽apache版本等敏感信息
#查看apache版本信息:[root@xuegod63 ~]# curl -I 192.168.1.63HTTP/1.1 200 OKDate: Sun, 15 Nov 2015 12:40:59 GMTServer: Apache/2.4.33 (Unix) mod_ssl/2.4.33 OpenSSL/1.0.0-fips PHP/5.4.14X-Powered-By: PHP/5.4.14Content-Type: text/html[root@xuegod63 ~]# curl -I www.baidu.com HTTP/1.1 200 OKAccept-Ranges: bytesCache-Control: private, no-cache, no-store, proxy-revalidate, no-transformConnection: Keep-AliveContent-Length: 277Content-Type: text/htmlDate: Mon, 16 Jul 2018 08:32:29 GMTEtag: "575e1f71-115"Last-Modified: Mon, 13 Jun 2016 02:50:25 GMTPragma: no-cacheServer: bfe/1.0.8.18[root@xuegod63 ~]# curl -I www.tencent.comHTTP/1.1 200 OKServer: NWS_UGC_HYConnection: keep-aliveDate: Mon, 16 Jul 2018 08:32:58 GMTCache-Control: max-age=600Expires: Mon, 16 Jul 2018 08:42:58 GMTLast-Modified: Fri, 17 Feb 2017 02:11:37 GMTContent-Type: text/htmlContent-Length: 189X-NWS-LOG-UUID: 0f1c8273-b0fa-4d9c-87ae-f6d9c5c8ca99 989f50f8bc1bbda11f966c017556085fX-Cache-Lookup: Hit From Disktank[root@xuegod63 ~]# curl -I www.taobao.comHTTP/1.1 302 FoundServer: TengineDate: Mon, 16 Jul 2018 08:33:17 GMTContent-Type: text/htmlContent-Length: 258Connection: keep-aliveLocation: https://www.taobao.com/Set-Cookie: thw=cn; Path=/; Domain=.taobao.com; Expires=Tue, 16-Jul-19 08:33:17 GMT;Strict-Transport-Security: max-age=315360001、我们在apache主配置文件httpd.conf中,找到包含httpd-default.conf的行,并解开注释[root@xuegod63 ~]# vim /usr/local/httpd/conf/httpd.conf486 #Include conf/extra/httpd-default.conf为:486 ??Include conf/extra/httpd-default.conf注意:编译安装的情况下,只有此行解开注释了,后面的修改才能生效。2)打开httpd-default.conf文件,修改如下两个地方[root@xuegod63 ~]# vim /usr/local/httpd/conf/extra/httpd-default.conf #修改如下行改: ???55 ServerTokens Full ???65 ServerSignature On为: ???ServerTokens Prod ???ServerSignature Off注: ?服务器标记产品 ???????服务器签名重启服务:[root@xuegod63 ~]# /etc/init.d/apachectl restart测试:[root@xuegod63 ~]# curl -I 192.168.1.63HTTP/1.1 200 OKDate: Sat, 29 Aug 2015 09:07:00 GMTServer: ApacheX-Powered-By: PHP/5.4.14Content-Type: text/html注:还是会出现信息:Server: Apache
LAMP之Apache调优
原文地址:https://www.cnblogs.com/happy1983/p/9318479.html