需要下载的额外的包:
apt-get install libpcre3 libpcre3-dev
apt-get install openssl libssl-dev
apt-get install libxml2 libxml2-dev
apt-get install libxslt-dev
apt-get install -y libgd-dev
简写:
apt install libpcre3 libpcre3-dev openssl libssl-dev libxml2 libxml2-dev libxslt-dev libgd-dev
其他基本操作见Nginx/Tengine 自编译说明 (yunsuo.com.cn)
1.18.0(Ubuntu 20.04)编译小结
执行
ps -elf | grep nginx
,获得nginx的地址备份nginx
cd /usr/sbin/
cp nginx nginx.bak
获得原nginx的配置信息
nginx -V
下载解压
nginx-1.18.0.tar.gz
和nginx-plugin-master.zip
cd ~
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar zxvf nginx-1.18.0.tar.gz
wget https://codeload.github.com/yunsuo-open/nginx-plugin/zip/master -O nginx-plugin-master.zip
unzip nginx-plugin-master.zip
(可能需要安装unzip)获得
nginx-plugin-master
的绝对地址cd nginx-plugin-master/
pwd
配置nginx
cd nginx-1.18.0/
./configure (之前nginx -V得到的) --add-module=/root/nginx-plugin-master
修改Makefile文件
VIM objs/Makefile
在Makefile文件中的CFLAGS=后追加宏定义 -DHIGHERTHAN8
修改ngx_modules.c文件
将
&ngx_http_yunsuo_module,
向下移动到ngx_http_userid_filter_module
和ngx_http_headers_filter_module
之间。编译nginx
make
替换原nginx
rm -rf /usr/sbin/nginx cp objs/nginx /usr/sbin/nginx service nginx restart