03_Nginx添加新模块



1 进入nginx安装目录,查看nginx版本及其编译参数:

[root@localhost nginx]# ./nginx -V

nginx version: nginx/1.8.0

built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)

built with OpenSSL 1.0.1c 10 May 2012

TLS SNI support enabled

configure arguments: --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.37 --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-1.0.1c --with-http_stub_status_module --user=nginx --group=nginx

[root@localhost nginx]#

2 进入nginx的源码目录:

[root@localhost src]# ls

nginx-1.8.0         openssl-1.0.1c         pcre-8.37         zlib-1.2.8

nginx-1.8.0.tar.gz  openssl-1.0.1c.tar.gz  pcre-8.37.tar.gz  zlib-1.2.8.tar.gz

[root@localhost src]# pwd

/usr/local/src

[root@localhost src]# cd nginx-1.8.0

[root@localhost nginx-1.8.0]# ls

auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src

[root@localhost nginx-1.8.0]#

3 以下是重新编译的代码和模块:

./configure --sbin-path=/usr/local/nginx/nginx \

--conf-path=/usr/local/nginx/nginx.conf \

--pid-path=/usr/local/nginx/nginx.pid \

--with-http_ssl_module \

--with-http_realip_module \

--with-http_addition_module \

--with-http_stub_status_module \

--with-http_sub_module \

--with-http_dav_module \

--with-http_flv_module \

--with-http_mp4_module \

--with-http_gunzip_module \

--with-http_gzip_static_module \

--with-http_random_index_module \

--with-http_secure_link_module \

--with-http_auth_request_module \

--with-mail \

--with-mail_ssl_module \

--with-file-aio \

--with-http_spdy_module \

--with-ipv6 \

--with-pcre=../pcre-8.37 \

--with-zlib=../zlib-1.2.8 \

--with-openssl=../openssl-1.0.1c \

--user=nginx \

--group=nginx;

截图如下:

详细参数请看官网:http://nginx.org/en/docs/configure.html

4 编译:

make   (注意:千万不要make install

5 make完成之后再当前目录下的objs目录下就多了个nginx,这个就是新版本的程序了

6 备份旧的nginx程序

[root@localhost objs]# cp /usr/local/nginx/nginx /usr/local/nginx/nginx.bak

 [root@localhost objs]# cd /usr/local/nginx/

[root@localhost nginx]# ls

client_body_temp        fastcgi_temp  mime.types.default  sbin                  uwsgi_temp

conf                    html          nginx               scgi_params           win-utf

fastcgi.conf            koi-utf       nginx.bak           scgi_params.default

fastcgi.conf.default    koi-win       nginx.conf          scgi_temp

fastcgi_params          logs          nginx.conf.default  uwsgi_params

fastcgi_params.default  mime.types    proxy_temp          uwsgi_params.default

[root@localhost nginx]#

6 把新的nginx程序覆盖旧的

[root@localhost nginx-1.8.0]# ls

auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src

[root@localhost nginx-1.8.0]# cp objs/nginx /usr/local/nginx/nginx

cp:是否覆盖"/usr/local/nginx/nginx" y

[root@localhost nginx-1.8.0]#

7 测试新的nginx程序是否正确

[root@localhost nginx-1.8.0]#/usr/local/nginx/nginx -t

8 平滑重启nginx

/usr/local/nginx/nginx –s reload

9 查看nginx版本及其编译参数:

/usr/local/nginx/nginx –V

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要在Nginx添加http_auth_request_module模块,你可以按照以下步骤操作: 1. 确认你的Nginx版本是否支持http_auth_request_module模块。你可以使用以下命令来检查: ``` nginx -V ``` 在输出结果中查找是否包含 "--with-http_auth_request_module" 字样,如果有,说明该模块已经被支持。 2. 如果你的Nginx版本不支持该模块,你需要重编译Nginx并启用该模块。首先,下载Nginx的源代码: ``` wget http://nginx.org/download/nginx-x.x.x.tar.gz ``` (将 "x.x.x" 替换为你想要下载的版本号) 3. 解压源代码包: ``` tar -zxvf nginx-x.x.x.tar.gz ``` 4. 进入解压后的目录: ``` cd nginx-x.x.x ``` 5. 执行以下命令进行配置,确保启用了http_auth_request_module模块: ``` ./configure --with-http_auth_request_module ``` 6. 执行以下命令编译并安装Nginx: ``` make sudo make install ``` 7. 配置Nginx的配置文件(通常是位于 /etc/nginx/nginx.conf)。在合适的位置添加以下配置项: ``` location / { auth_request /auth; ... } location = /auth { internal; proxy_pass http://auth_backend; ... } ``` 这里的 "/auth" 是用来处理认证请求的URL,你可以根据需要进行修改。"http://auth_backend" 是实际处理认证请求的后端服务地址,也需要根据实际情况进行修改。 8. 保存并关闭配置文件后,重启Nginx服务: ``` sudo service nginx restart ``` 现在,你已经成功地添加了http_auth_request_module模块Nginx中。你可以根据实际需求进一步配置和使用该模块来进行认证授权操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

涂作权的博客

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值