1.nginx下载

  下载网址:nginx.org

2.解压nginx

[root@iZwz9cl4i8oy1reej7o8pmZ soft]# ls
nginx-.tar.gz
[root@iZwz9cl4i8oy1reej7o8pmZ soft]# .tar.gz 

3.修改源码

[root@iZwz9cl4i8oy1reej7o8pmZ soft]# ls
nginx-  nginx-.tar.gz#进入nginx源码包
[root@iZwz9cl4i8oy1reej7o8pmZ soft]# cd nginx-
[root@iZwz9cl4i8oy1reej7o8pmZ nginx-]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[root@iZwz9cl4i8oy1reej7o8pmZ nginx-]# 

  修改nginx.h文件

[root@iZwz9cl4i8oy1reej7o8pmZ nginx-]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[root@iZwz9cl4i8oy1reej7o8pmZ nginx-]# cd src/core/
[root@iZwz9cl4i8oy1reej7o8pmZ core]# vim nginx.h
[root@iZwz9cl4i8oy1reej7o8pmZ core]# 

  修改后如下:

   #ifndef _NGINX_H_INCLUDED_
   #define _NGINX_H_INCLUDED_

  #define nginx_version      1010003      
  #define NGINX_VERSION      "0.0.1"            #NGINX对外显示的版本号
  #define NGINX_VER          "LiWang/" NGINX_VERSION   #NGINX对外显示的服务器名

  #ifdef NGX_BUILD
  #define NGINX_VER_BUILD    NGINX_VER " (" NGX_BUILD ")"
  #else
  #define NGINX_VER_BUILD    NGINX_VER
  #endif

  #define NGINX_VAR          "NGINX"
  #define NGX_OLDPID_EXT     ".oldbin"

  #endif /* _NGINX_H_INCLUDED_ */

  修改ngx_http_special_response.c内容

#进入src/http文件夹下
[root@iZwz9cl4i8oy1reej7o8pmZ http]# pwd
/root/soft/nginx-/src/http#利用vim编辑ngx_http_special_response.c文件
[root@iZwz9cl4i8oy1reej7o8pmZ http]# vim ngx_http_special_response.c 
 #修改结果如下 static ngx_int_t ngx_http_send_error_page(ngx_http_request_t *r,
      ngx_http_err_page_t *err_page);
  static ngx_int_t ngx_http_send_special_response(ngx_http_request_t *r,
      ngx_http_core_loc_conf_t *clcf, ngx_uint_t err);
  static ngx_int_t ngx_http_send_refresh(ngx_http_request_t *r);

  static u_char ngx_http_error_full_tail[] =
  "<hr><center>" NGINX_VER "Server:LiWang blog:www.cnblogs.com/wang-li</center>" CRLF
  "</body>" CRLF
  "</html>" CRLF
  ;

  static u_char ngx_http_error_tail[] =
  "<hr><center>nginx</center>" CRLF
  "</body>" CRLF
  "</html>" CRLF
  ;

  编辑vim ngx_http_header_filter_module.c 文件

[root@iZwz9cl4i8oy1reej7o8pmZ http]# pwd
/root/soft/nginx-/src/http
[root@iZwz9cl4i8oy1reej7o8pmZ http]# vim ngx_http_header_filter_module.c 

  修改结果如下


  static char ngx_http_server_string[] = "Server: LiWang" CRLF;
  static char ngx_http_server_full_string[] = "http://www.cnblogs.com/wang-li" NGINX_VER CRLF;

  static ngx_str_t ngx_http_status_lines[] = {

      ngx_string("200 OK"),
      ngx_string("201 Created"),
      ngx_string("202 Accepted"),
      ngx_null_string,  /* "203 Non-Authoritative Information" */
      ngx_string("204 No Content"),
      ngx_null_string,  /* "205 Reset Content" */
      ngx_string("206 Partial Content"),

      /* ngx_null_string, */  /* "207 Multi-Status" */

  #define NGX_HTTP_LAST_2XX  207
  #define NGX_HTTP_OFF_3XX   (NGX_HTTP_LAST_2XX - 200)

4.开始进行源码编译

  安装必要的插件

[root@iZwz9cl4i8oy1reej7o8pmZ nginx-]# yum install -y pcre pcre-devel zlib zlib-devel

  添加nginx用户

[root@iZwz9cl4i8oy1reej7o8pmZ nginx-]# useradd nginx -s /sbin/nologin
[root@iZwz9cl4i8oy1reej7o8pmZ nginx-]#  /etc/passwd
nginx:x::::/home/nginx:/sbin/nologin

  开始进行编译

[root@iZwz9cl4i8oy1reej7o8pmZ nginx-]# ./configure --prefix=/usr/local/nginx-1.10 --user=nginx --group=nginx

  出现如下信息则为制作ok

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using builtin md5 code
  + sha1 library is not found
  + using system zlib library

  nginx path prefix: "/usr/local/nginx-1.10"
  nginx binary file: "/usr/local/nginx-1.10/sbin/nginx"
  nginx modules path: "/usr/local/nginx-1.10/modules"
  nginx configuration prefix: "/usr/local/nginx-1.10/conf"
  nginx configuration file: "/usr/local/nginx-1.10/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx-1.10/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx-1.10/logs/error.log"
  nginx http access log file: "/usr/local/nginx-1.10/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

  开始make and make install

[root@iZwz9cl4i8oy1reej7o8pmZ nginx-]# make && make install

5.开始配置

  配置参照网址:

  http://www.cnblogs.com/wang-li/p/6689615.html

  配置过后进行访问

[root@iZwz9cl4i8oy1reej7o8pmZ conf]# curl -I www.wang-li.top:
HTTP/ OK
Server: LiWang
Date: Tue,  Apr  :: GMT
Content-Type: text/html
Content-Length:
Last-Modified: Sun,  Mar  :: GMT
Connection: keep-alive
ETag: "58d7c75c-230"
Accept-Ranges: bytes

[root@iZwz9cl4i8oy1reej7o8pmZ conf]# 

nginx调优操作之nginx隐藏其版本号的更多相关文章

  1. 隐藏Nginx或Apache以及PHP的版本号的方法

    当黑客入侵一台服务器时,首先会”踩点”, 这里的”踩点”,指的是了解服务器中运行的一些服务的详细情况,比如说:版本号,当黑客知道相应服务的版本号后,就可以寻找该服务相应版本的一些漏洞来入侵,攻击,所以 ...

  2. 使用nginx反向代理实现隐藏端口号

    使用nginx反向代理实现隐藏端口号 在服务器上下载安装nginx,主要是修改配置nginx.conf. 用proxy_pass里面配置要转发的域名+端口,相当于这一部分是被域名替换的部分,在http ...

  3. nginx是什么nginx安装与配置之windows版

    1.nginx是什么 为了快速了解nginx我们先引用网上的nginx介绍: Nginx ("engine x") 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP ...

  4. 【学习笔记】启动Nginx、查看nginx进程、查看nginx服务主进程的方式、Nginx服务可接受的信号、nginx帮助命令、Nginx平滑重启、Nginx服务器的升级

     1.启动nginx的方式: cd /usr/local/nginx ls ./nginx -c nginx.conf 2.查看nginx的进程方式: [root@localhost nginx] ...

  5. 快速掌握Nginx(一) —— 安装Nginx和简单配置虚拟主机

    Nginx安装和简单配置虚拟主机 1 Nginx简介 Nginx是近几年最火热的http.反向代理服务器,百度阿里等互联网公司也都在使用Nginx,它也可以用作邮件代理服务器.TCP/UDP代理服务器 ...

  6. Nginx 相关介绍(Nginx是什么?能干嘛?)

    Nginx的产生 没有听过Nginx?那么一定听过它的"同行"Apache吧!Nginx同Apache一样都是一种WEB服务器.基于REST架构风格,以统一资源描述符(Unifor ...

  7. 部署Asp.net core & Nginx,通过nginx转发

    部署Asp.net core & Nginx,通过nginx转发 CentOS 7 x64 1.vs2017 建立Asp.net core项目,并发布到目录 2.通过FTP工具,将程序copy ...

  8. Windows7安装nginx后,'nginx -t -c nginx.conf' 命令出现 “could not open error log file: CreateFile() "logs/error.log" failed” 错误的原因

    网上搜索安装nginx的方法,按照步骤在 http://nginx.org/en/download.html 下载了安装包,并配置了conf/nginx.conf,将nginx的根目录添加进了环境变量 ...

  9. Nginx配置文件(nginx.conf)配置具体解释

    欢迎扫码增加Java高知群交流 Nginx的配置文件nginx.conf配置具体解释例如以下:   user nginx nginx ; Nginx用户及组:用户 组. window下不指定   wo ...

随机推荐

  1. 29-jsp中用js进行时间格式转化

    CST可以为如下4个不同的时区的缩写: 美国中部时间:Central Standard Time (USA) UT-6:00 澳大利亚中部时间:Central Standard Time (Austr ...

  2. gearman的持久化,以mysql的方式

    1.为什么要持久化? gearman的job server中的工作队列存储在内存中,一旦服务器有未处理的任务时重启或者宕机,那么这些任务就会丢失.持久化存储队列可以允许添加后台任务,并将其存储在外部的 ...

  3. vue项目网站换肤

    由于我网站不是的单色,换动的样式有点多,所以我只能通过后端传给我的不同的皮肤类型,来控制不同的样式文件 在网上查了一堆,每一个有用的 if(store.getters.infoType==1){ re ...

  4. Android Studio 解析json文件出现中文乱码解决方法

    作为一个Android开发初学者,好不容易找到解决方法,跟大家分享一下, 其实很简单,只要保持服务器上的文件(date2.json)与软件的编码方式一样就行. 我用的Android Studio是ut ...

  5. 1F - A+B for Input-Output Practice (III)

    Your task is to Calculate a + b. Input Input contains multiple test cases. Each test case contains a ...

  6. (轉)JSON.stringify 语法实例讲解

    作用:这个函数的作用主要是为了系列化对象的. 可能有些人对系列化这个词过敏,我的理解很简单.就是说把原来是对象的类型转换成字符串类型(或者更确切的说是json类型的).就这么简单.打个比方说,你有一个 ...

  7. Zookeeper简介与使用

    1.   Zookeeper概念简介: Zookeeper是一个分布式协调服务:就是为用户的分布式应用程序提供协调服务 A.zookeeper是为别的分布式程序服务的 B.Zookeeper本身就是一 ...

  8. iOS.Objective-C.Dependency.Graphing-v0.1

    当Project越来越复杂,模块间的依赖就会很复杂,不合理的依赖就出现:不必要的依赖,双向依赖等等. 在iOS Application Project中可以将依赖定义为:对某个头文件的import. ...

  9. linux查看文件被哪个进程占用?

    1> 如果文件是端口号 netstat -ntlp | grep portNum [root@localhost root]# netstat -ntlp Active Internet con ...

  10. mysql 5.17 的update失败问题

    在使用workbench的时候,写入update语句,会很提现失败,原因是安全模式; 可能是workbench在数据库更新的时候是有限制的,防止错误哦l 更改方法也很简单; Edit - Profer ...