CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本

本文详细介绍Nginx的下载、解压、预编译安装步骤,并提供了隐藏Nginx版本的方法,包括核心文件的修改及编译参数设置。此外还介绍了如何通过环境变量简化Nginx的管理和操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.下载

      [root@localhost ~]# cd /usr/local/src/

      [root@localhost src]#  wget   http://nginx.org/download/nginx-1.12.2.tar.gz

2.解压

     [root@localhost src]# tar zxvf nginx-1.12.2.tar.gz 

3. 预编译

安装前确认安装扩展 没有的直接 yum install wget gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel 

如果要隐藏nginx的版本可以

 (1).修改  nginx-1.12.2/src/core/nginx.h  文件


(2)src/http下的ngx_http_header_filter_module.c文件

vim src/http/ngx_http_header_filter_module.c


(3) src/http下的ngx_http_special_response.c文件 


然后编译 nginx伪装成SSI

  [root@localhost src]# cd nginx-1.12.2 

   [root@localhost nginx-1.12.2]# ./configure --prefix=/usr/local/nginx    --with-http_ssl_module   --with-http_v2_module --with-http_stub_status_module   --with-pcre  --with-http_gzip_static_module  

解释
--with-http_gzip_static_module :支持压缩
--with-http_stub_status_module :支持nginx状态查询
--with-http_ssl_module :支持https
--with-http_spdy_module :支持google的spdy,想了解请百度spdy,这个必须有ssl的支持
--with-pcre :为了支持rewrite重写功能,必须制定pcre
可根据自己需求
4. [root@localhost src]# make && make install 

         echo $?   意思为上一步的执行结果 0意思成功

   

5.添加系统变量(方便启停服务)

 [root@localhost nginx-1.12.2]# vim /etc/profile
   我一般是在56行添加    export PATH=/usr/local/nginx/sbin:$PATH
       

  [root@localhost nginx-1.12.2]#source /etc/profile
添加到系统路径就可以直接用了
    [root@localhost nginx-1.12.2]# nginx -V

   

  隐藏后的在服务器看


  会显示编译时的详细信息 就可以直接操作启动 停止了

    [root@localhost nginx-1.12.2]# nginx -s reload



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

舰长115

码字不易如果觉得还不错谢谢鼓励

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值