nginx 编译 带 http_rewrite_module
时间: 2023-11-30 13:05:24 浏览: 35
要编译带有http_rewrite_module的nginx,可以按照以下步骤操作:
1. 先下载nginx的源码包,可以到官网 https://nginx.org/en/download.html 下载最新版本的源码包。
2. 解压缩源码包,进入解压缩后的nginx目录。
3. 执行以下命令,安装依赖库:
```
sudo apt-get install build-essential libpcre3 libpcre3-dev zlib1g-dev
```
4. 执行以下命令进行编译:
```
./configure --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_slice_module --with-threads --with-stream --with-stream_ssl_module --with-stream_realip_module --add-module=/path/to/ngx_http_rewrite_module
```
其中,`/path/to/ngx_http_rewrite_module`需要替换成你实际安装ngx_http_rewrite_module模块的路径。
5. 执行以下命令进行编译和安装:
```
make && sudo make install
```
注意,这个过程可能要花费一些时间,具体时间取决于你的机器性能和网络情况。
6. 安装完成后,可以在nginx的配置文件中使用rewrite指令了。