1.下载

      [[email protected] ~]# cd /usr/local/src/

      [[email protected] src]#  wget   http://nginx.org/download/nginx-1.12.2.tar.gz

2.解压

     [[email protected] 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  文件

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

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

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

vim src/http/ngx_http_header_filter_module.c

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

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

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

然后编译 nginx伪装成SSI

  [[email protected] src]# cd nginx-1.12.2 

   [[email protected] 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. [[email protected] src]# make && make install 

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

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

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

 [[email protected] nginx-1.12.2]# vim /etc/profile
   我一般是在56行添加    export PATH=/usr/local/nginx/sbin:$PATH
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本       CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本

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

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

  隐藏后的在服务器看

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

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

    [[email protected] nginx-1.12.2]# nginx -s reload



相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2021-05-30
  • 2022-12-23
  • 2021-06-01
  • 2021-11-05
猜你喜欢
  • 2021-11-17
  • 2021-09-07
  • 2021-08-26
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案