蔬菜小程序的开发全流程详解
788
2022-09-22
隐藏apache版本信息
隐藏apache版本信息
######################################33
隐藏Apache信息
[root@LAMP ~]# curl -I 127.0.0.1
HTTP/1.1 200 OK
Date: Thu, 24 Sep 2015 01:47:29 GMT
Server: Apache/2.2.27 (Unix) DAV/2 PHP/5.3.27
X-Powered-By: PHP/5.3.27
Content-Type: text/html
##由此可见版本号为2.2.27
[root@LAMP ~]#
1 主配置中启用vi /application/apache/conf/conf/extra//application/apache/conf/
grep "Include conf/extra/-i 's$#Include conf/extra/conf/extra/"Include conf/extra/Full
ServerSignature On
改成
ServerTokens Prod
ServerSignature off
########
或者用sed命令
cd /application/apache/conf/extra/
egrep "ServerTokens Full|ServerSignature On" -i 's/ServerTokens Full/ServerTokens Prod/g' -i 's/ServerSignature On/ServerSignature off/g' "ServerTokens |ServerSignature " conf]# cd /application/apache/conf/extra/
[root@LAMP extra]# egrep "ServerTokens Full|ServerSignature On" Full
ServerSignature On
[root@LAMP extra]# sed -i 's/ServerTokens Full/ServerTokens Prod/g' extra]# sed -i 's/ServerSignature On/ServerSignature off/g' extra]# egrep "ServerTokens |ServerSignature " -I 10.0.0.3
/application/apache/bin/apachectl graceful
curl -I 10.0.0.3
[root@LAMP extra]# /application/apache/bin/apachectl graceful
[root@LAMP extra]# curl -I 10.0.0.3
HTTP/1.1 200 OK
Date: Thu, 24 Sep 2015 01:54:18 GMT
Server: Apache
X-Powered-By: PHP/5.3.27
Content-Type: text/html
##由此可见版本号2.2.27不见了。但是版本apache还在
[root@LAMP extra]#
上面的方法只能修改版本号,不能改变版本,如果需要改变版本,是默认情况下安装的Apache,如果是编译安装的,还可以用修改源码编译的方法:
修改下面两个文件的内容:
/home/lvnian/tools//home/lvnian/tools//home/lvnian/tools//home/lvnian/tools//home/lvnian/tools/#define AP_SERVER_BASEVENDOR "Apache Software Foundation"
41 #define AP_SERVER_BASEPROJECT "Apache HTTP Server"
42 #define AP_SERVER_BASEPRODUCT "Apache"
43
44 #define AP_SERVER_MAJORVERSION_NUMBER 2
45 #define AP_SERVER_MINORVERSION_NUMBER 2
46 #define AP_SERVER_PATCHLEVEL_NUMBER 27
47 #define AP_SERVER_DEVBUILD_BOOLEAN 0
修改成下面内容
40 #define AP_SERVER_BASEVENDOR "lvnian IIS6 Software Foundation"
41 #define AP_SERVER_BASEPROJECT "lvnian IIS6 HTTP Server"
42 #define AP_SERVER_BASEPRODUCT "lvnian IIS6 "
43
44 #define AP_SERVER_MAJORVERSION_NUMBER 1
45 #define AP_SERVER_MINORVERSION_NUMBER 3
46 #define AP_SERVER_PATCHLEVEL_NUMBER 5
47 #define AP_SERVER_DEVBUILD_BOOLEAN 7
###########################3
用sed 修改如下:
grep -n '"Apache' /home/lvnian/tools//home/lvnian/tools/-i 's/"Apache/"lvnian IIS6/g' ap_release.h
sed -n '40,42p' ap_release.h
sed -n '44,47p' ap_release.h
grep "AP_SERVER_MAJORVERSION_NUMBER 2" ap_release.h
sed -i 's/AP_SERVER_MAJORVERSION_NUMBER 2/AP_SERVER_MAJORVERSION_NUMBER 1/g' ap_release.h
sed -i 's/AP_SERVER_MINORVERSION_NUMBER 2/AP_SERVER_MINORVERSION_NUMBER 3/g' ap_release.h
sed -i 's/AP_SERVER_PATCHLEVEL_NUMBER 27/AP_SERVER_PATCHLEVEL_NUMBER 5/g' ap_release.h
sed -i 's/AP_SERVER_DEVBUILD_BOOLEAN 0/AP_SERVER_DEVBUILD_BOOLEAN 7/g' ap_release.h
sed -n '44,47p' ap_release.h
sed -n '39,47p' ap_release.h
############sed 命令过程
[root@LAMP ~]# grep -n '"Apache' /home/lvnian/tools/* Example: "Apache/1.1.0 MrWidget/0.1-alpha"
40:#define AP_SERVER_BASEVENDOR "Apache Software Foundation"
41:#define AP_SERVER_BASEPROJECT "Apache HTTP Server"
42:#define AP_SERVER_BASEPRODUCT "Apache"
[root@LAMP ~]# cd /home/lvnian/tools/include]# sed -i 's/"Apache/"lvnian IIS6/g' ap_release.h
[root@LAMP include]# sed -n '40,42p' ap_release.h
#define AP_SERVER_BASEVENDOR "lvnian IIS6 Software Foundation"
#define AP_SERVER_BASEPROJECT "lvnian IIS6 HTTP Server"
#define AP_SERVER_BASEPRODUCT "lvnian IIS6"
[root@LAMP include]# sed -n '44,47p' ap_release.h
#define AP_SERVER_MAJORVERSION_NUMBER 2
#define AP_SERVER_MINORVERSION_NUMBER 2
#define AP_SERVER_PATCHLEVEL_NUMBER 27
#define AP_SERVER_DEVBUILD_BOOLEAN 0
[root@LAMP include]# grep "AP_SERVER_MAJORVERSION_NUMBER 2" ap_release.h
#define AP_SERVER_MAJORVERSION_NUMBER 2
[root@LAMP include]# sed -i 's/AP_SERVER_MAJORVERSION_NUMBER 2/AP_SERVER_MAJORVERSION_NUMBER 1/g' ap_release.h
[root@LAMP include]# sed -i 's/AP_SERVER_PATCHLEVEL_NUMBER 27/AP_SERVER_PATCHLEVEL_NUMBER 5/g' ap_release.h
[root@LAMP include]# sed -i 's/AP_SERVER_DEVBUILD_BOOLEAN 0/AP_SERVER_DEVBUILD_BOOLEAN 7/g' ap_release.h
[root@LAMP include]# sed -n '44,47p' ap_release.h
#define AP_SERVER_MAJORVERSION_NUMBER 1
#define AP_SERVER_MINORVERSION_NUMBER 3
#define AP_SERVER_PATCHLEVEL_NUMBER 5
#define AP_SERVER_DEVBUILD_BOOLEAN 7
#############################################################################3
修改 /home/lvnian/tools/,修改成你想要修改的内容
35 #define PLATFORM "Unix"
如修改成
#define PLATFORM "win32"
sed命令如下
cd /home/lvnian/tools/-n '/#define PLATFORM /p' os.h
sed -i 's/#define PLATFORM "Unix"/#define PLATFORM "LVNIAN WIN"/g' os.h
sed -n '/#define PLATFORM /p' os.h
##########
[root@LAMP unix]# sed -n '/#define PLATFORM /p' os.h
#define PLATFORM "Unix"
[root@LAMP unix]# sed -i 's/#define PLATFORM "Unix"/#define PLATFORM "LVNIAN WIN"/g' os.h
[root@LAMP unix]# sed -n '/#define PLATFORM /p' os.h
#define PLATFORM "LVNIAN WIN"
[root@LAMP unix]#
记得要上面的都不需要把#注销去掉
备份配置文件,
重新编译安装
pkill -rf /application/apache2.22.27
cd /home/lvnian/tools
cd \
--prefix=/application/apache2.22.27 \
--enable-deflate \
--enable-expires \
--enable-headers \
--enable-modules=most \
--enable-so \
--with-mpm=worker \
--enable-rewrite
make && make install
##解决启动apache慢问题
grep -i "#ServerName" /application/apache/conf/-i '/#ServerName/aServerName 127.0.0.1:80' /application/apache/conf/-i "ServerName" /application/apache/conf/-lnt
/application/apache/bin/apachectl -t
/application/apache/bin/apachectl start
##测试
[root@LAMP curl -I 10.0.0.3
HTTP/1.1 200 OK
Date: Thu, 24 Sep 2015 02:55:18 GMT
Server: lvnian IIS6/1.3.5-dev (LVNIAN WIN) DAV/2
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "20c8e-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Content-Type: text/html
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~