方式一:基于修改配置文件
# vim /usr/local/nginx/conf/nginx.conf//编辑主配置文件
//第二十行添加
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;# service nginx reload //重启服务
# curl -I http://192.168.116.133 //再次检测
方式二:(前提条件:nginx是编译安装)基于修改源码包文件
注意:先修改源码包文件再进行编译安装,如果是已经编译安装了nginx,修改源码包文件后重新编译安装一下。
我这里是先修改源码包又进行的编译安装。
[root@zabbix nginx-1.16.1]# vim ./src/core/nginx.h 修改源码包文件
#define nginx_version 1012000
#define NGINX_VERSION "1.1.5"
#define NGINX_VER "IIS/" NGINX_VERSION
//更改版本号,注意不用取消井号!
修改后进行编译安装
[root@zabbix nginx-1.16.1]# ./configure --prefix=/application/nginx-1.16.1/ --sbin-path=/usr/bin/ --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --add-module=../ngx_cache_purge-2.3
安装完成后测试查看
[root@zabbix nginx-1.16.1]# curl -I 10.0.0.71
HTTP/1.1 200 OK
Server: IIS/1.1.5 #注意这里,已经改变
Date: Sun, 29 Mar 2020 01:37:38 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Sun, 29 Mar 2020 01:37:09 GMT
Connection: keep-alive
ETag: "5e7ffbc5-264"
Accept-Ranges: bytes