Hide Apache Version Information
##################################### #33
Hide Apache Information
[Email protected] ~]# curl-i 127.0.0.1
http/1.1 OK
Date:thu, Sep 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
[Email protected] ~]#
1 Enable httpd-default.conf in master configuration
# vi/application/apache/conf/httpd. Conf
Find httpd-default.conf, delete the "#" in front of includes, and change to the following
Include conf/extra/httpd-default.conf
or with the SED command.
cd/application/apache/conf/
grep "Include conf/extra/httpd-default.conf" httpd.conf
Sed-i ' s $ #Include conf/extra/httpd-default.conf$include conf/extra/httpd-default.conf$g ' httpd.conf
grep "Include conf/extra/httpd-default.conf" httpd.conf
Modify Httpd-default.conf
Files:/application/apache/conf/extra/httpd-default.conf
Found it
Servertokens full
Serversignature on
Change into
Servertokens Prod
Serversignature off
########
or with the SED command.
cd/application/apache/conf/extra/
Egrep "Servertokens full| Serversignature on "httpd-default.conf
Sed-i ' s/servertokens full/servertokens prod/g ' httpd-default.conf
Sed-i ' s/serversignature on/serversignature off/g ' httpd-default.conf
Egrep "Servertokens | Serversignature "httpd-default.conf
######## #sed过程
[Email protected] conf]# cd/application/apache/conf/extra/
[Email protected] extra]# egrep "Servertokens full| Serversignature on "httpd-default.conf
Servertokens full
Serversignature on
[Email protected] extra]# sed-i ' s/servertokens full/servertokens prod/g ' httpd-default.conf
[Email protected] extra]# sed-i ' s/serversignature on/serversignature off/g ' httpd-default.conf
[Email protected] extra]# Egrep "Servertokens | Serversignature "httpd-default.conf
####################
Restart Apache to see if the version number has been modified
Curl-i 10.0.0.3
/application/apache/bin/apachectl Graceful
Curl-i 10.0.0.3
[Email protected] extra]#/application/apache/bin/apachectl Graceful
[Email protected] extra]# curl-i 10.0.0.3
http/1.1 OK
Date:thu, Sep 01:54:18 GMT
Server:apache
x-powered-by:php/5.3.27
Content-type:text/html
# #由此可见版本号2.2.27 was gone. But version Apache is still in
[Email protected] extra]#
The above method can only modify the version number, can not change the version, if you need to change the version, is installed by default Apache, if the installation is compiled, you can also use to modify the source code compiled method:
Modify the contents of the following two files:
/home/lvnian/tools/httpd-2.2.27/include/ap_release.h
/home/lvnian/tools/httpd-2.2.27/os/unix/os.h
Cp/home/lvnian/tools/httpd-2.2.27/include/ap_release.h/home/lvnian/tools/httpd-2.2.27/include/ap_release.h.ori
Cp/home/lvnian/tools/httpd-2.2.27/os/unix/os.h/home/lvnian/tools/httpd-2.2.27/os/unix/os.h.ori
The contents of the amendment are as follows:
#####################
#define Ap_server_basevendor "Apache software Foundation"
#define Ap_server_baseproject "Apache HTTP SERVER"
#define AP_SERVER_BASEPRODUCT "Apache"
43
#define Ap_server_majorversion_number 2
#define Ap_server_minorversion_number 2
#define Ap_server_patchlevel_number 27
#define Ap_server_devbuild_boolean 0
Modify to the following content
#define Ap_server_basevendor "Lvnian IIS6 software Foundation"
#define Ap_server_baseproject "Lvnian IIS6 HTTP SERVER"
#define AP_SERVER_BASEPRODUCT "Lvnian IIS6"
43
#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
Use SED to modify the following:
Grep-n ' Apache '/home/lvnian/tools/httpd-2.2.27/include/ap_release.h
cd/home/lvnian/tools/httpd-2.2.27/include/
Sed-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 Command procedure
[Email protected] ~]# grep-n ' Apache '/home/lvnian/tools/httpd-2.2.27/include/ap_release.h
* Example: "apache/1.1.0 mrwidget/0.1-alpha"
Max: #define Ap_server_basevendor "Apache software Foundation"
In: #define Ap_server_baseproject "Apache HTTP SERVER"
: #define AP_SERVER_BASEPRODUCT "Apache"
[Email protected] ~]# cd/home/lvnian/tools/httpd-2.2.27/include/
[Email protected] include]# sed-i ' s/"apache/" Lvnian iis6/g ' ap_release.h
[Email protected] 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"
[Email protected] 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
[[email protected] include]# grep "Ap_server_majorversion_number 2" ap_release.h
#define Ap_server_majorversion_number 2
[Email protected] include]# sed-i ' s/ap_server_majorversion_number 2/ap_server_majorversion_number 1/g ' ap_release.h
[Email protected] include]# sed-i ' s/ap_server_patchlevel_number 27/ap_server_patchlevel_number 5/g ' ap_release.h
[Email protected] include]# sed-i ' s/ap_server_devbuild_boolean 0/ap_server_devbuild_boolean 7/g ' ap_release.h
[Email protected] 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
Modify the following contents of the/home/lvnian/tools/httpd-2.2.27/os/unix/os.h file to modify what you want to modify
#define PLATFORM "Unix"
If you modify it into
#define PLATFORM "Win32"
The SED command is as follows
cd/home/lvnian/tools/httpd-2.2.27/os/unix/
Sed-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
##########
[[email protected] unix]# sed-n '/#define PLATFORM/P ' Os.h
#define PLATFORM "Unix"
[Email protected] unix]# sed-i ' s/#define PLATFORM "UNIX"/#define PLATFORM "Lvnian WIN"/g ' os.h
[[email protected] unix]# sed-n '/#define PLATFORM/P ' Os.h
#define PLATFORM "Lvnian WIN"
[Email protected] unix]#
Remember, there's no need to get the sign off.
Backup configuration files,
Recompile the installation
Pkill httpd
rm-rf/application/apache2.22.27
Cd/home/lvnian/tools
CD httpd-2.2.27
./configure \
--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/httpd.conf
Sed-i '/#ServerName/aservername 127.0.0.1:80 '/application/apache/conf/httpd.conf
Grep-i "ServerName"/application/apache/conf/httpd.conf
# #启动apache
Pkill httpd
Netstat-lnt
/application/apache/bin/apachectl-t
/application/apache/bin/apachectl start
# #测试
[Email protected] httpd-2.2.27]# curl-i 10.0.0.3
http/1.1 OK
Date:thu, Sep 02:55:18 GMT
Server:lvnian Iis6/1.3.5-dev (Lvnian WIN) DAV/2
Last-modified:sat, 2004 20:16:24 GMT
ETag: "20c8e-2c-3e9564c23b600"
Accept-ranges:bytes
Content-length:44
Content-type:text/html
This article is from the "Technology Change Destiny" blog, please be sure to keep this source http://lvnian.blog.51cto.com/7155281/1697744
Hide Apache Version Information