Nginx 笔记
Summary: Author: 张亚飞 | Read Time: 9 minute read | Published: 2016-08-08
Filed under
—
Categories:
DevOps
—
Tags:
Linux,
Server,
Software,
DevOps,
不错的Nginx开发者博客
使用 Nginx 编译安装第三方模块
- 添加
pagespeed
模块
/opt/data/ngx-m
wget https://github.com/pagespeed/ngx_pagespeed/archive/latest-stable.tar.gz
tar -zxvf latest-stable.tar.gz
/opt/data/ngx-m/incubator-pagespeed-ngx-latest-stable
cd incubator-pagespeed-ngx-latest-stable
wget https://dl.google.com/dl/page-speed/psol/1.13.35.2-x64.tar.gz
// extracts to `psol/`
tar -xzvf 1.13.35.2-x64.tar.gz
2.Get Nginx Sources & Dependencies
First, edit the PPA’s sources file and ensure the deb-src directive is not commented out. This will let us get the sources files:
首先,也需要添加 Nginx ppa
源 https://launchpad.net/~nginx/+archive/ubuntu/stable
sudo apt install software-properties-common python-software-properties
sudo add-apt-repository -y ppa:nginx/stable
sudo apt update
查看 nginx-stable-trusty.list
并取消默认注释为 (Ubuntu16.04 变成为 /etc/apt/sources.list.d/nginx-ubuntu-stable-xenial.list
)
vi /etc/apt/sources.list.d/nginx-stable-trusty.list
deb http://ppa.launchpad.net/nginx/stable/ubuntu trusty main
deb-src http://ppa.launchpad.net/nginx/stable/ubuntu trusty main
修改源后更新
sudo apt update
由此,我们可以继续获取 Nginx 的源码包,修改编译最后完成安装
首先我们获取 nginx 源码并且安装系统依赖
# Install package creation tools
sudo apt install -y dpkg-dev
sudo mkdir /opt/data/rebuildnginx
cd /opt/data/rebuildnginx
# Get Nginx (ppa:nginx/stable) source files
sudo apt source nginx
# Install the build dependencies
sudo apt build-dep nginx
最后,我们可以看到如下目录文件
coam@coamn:/opt/data/rebuildnginx$ ls -lah
total 1.9M
drwxr-xr-x 3 root root 4.0K May 8 11:57 .
drwxr-xr-x 7 root root 4.0K May 8 11:57 ..
drwxr-xr-x 10 root root 4.0K May 8 11:57 nginx-1.10.0
-rw-r--r-- 1 root root 977K May 6 04:40 nginx_1.10.0-0+trusty0.debian.tar.gz
-rw-r--r-- 1 root root 2.7K May 6 04:40 nginx_1.10.0-0+trusty0.dsc
-rw-r--r-- 1 root root 888K May 6 04:40 nginx_1.10.0.orig.tar.gz
The ppa:nginx/stable has multiple Nginx packages available: common, light, full and extras.
/opt/data/rebuildnginx/nginx-1.10.0/debian/rules
修改 full_configure_flags 部分如下
full_configure_flags := \
$(common_configure_flags) \
--with-http_addition_module \
--with-http_dav_module \
--with-http_geoip_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_image_filter_module \
--with-http_v2_module \
--with-http_sub_module \
--with-http_xslt_module \
--with-stream \
--with-stream_ssl_module \
--with-mail \
--with-mail_ssl_module \
--with-threads \
--add-module=$(MODULESDIR)/nginx-auth-pam \
--add-module=$(MODULESDIR)/nginx-dav-ext-module \
--add-module=$(MODULESDIR)/nginx-echo \
--add-module=$(MODULESDIR)/nginx-upstream-fair \
--add-module=$(MODULESDIR)/ngx_http_substitutions_filter_module \
--add-module=/opt/pagespeed/ngx_pagespeed-release-1.11.33.1-beta
- 注以前的
...
--add-module=$(MODULESDIR)/nginx-auth-pam \
--add-module=$(MODULESDIR)/nginx-dav-ext-module \
--add-module=$(MODULESDIR)/nginx-echo \
--add-module=$(MODULESDIR)/nginx-upstream-fair \
--add-module=$(MODULESDIR)/ngx_http_substitutions_filter_module \
--add-module=/opt/pagespeed/ngx_pagespeed-release-1.9.32.6-beta \
--add-module=/opt/lua-nginx-module \
--add-module=/opt/naxsi/naxsi_src \
--add-module=/opt/ModSecurity-2.9.0/nginx/modsecurity
...
修改完后,可以执行如下命令编译 Nginx!
cd /opt/data/rebuildnginx/nginx-1.10.0
sudo dpkg-buildpackage -b
注意,如果执行安装命令 sudo dpkg-buildpackage -b 出现类似 ×changes: clearsign failed: No secret key× 错误,则按如下在添加 “dpkg-buildpackage us uc”
sudo dpkg-buildpackage -b -uc -us
一旦编译完成,我们可以在 /opt/data/rebuildnginx/ 下添加了 .deb 文件
coam@coamn:/opt/data/rebuildnginx$ ls -al
total 45820
drwxr-xr-x 3 root root 4096 May 8 12:26 .
drwxr-xr-x 7 root root 4096 May 8 11:57 ..
drwxr-xr-x 10 root root 4096 May 8 11:57 nginx-1.10.0
-rw-r--r-- 1 root root 23526 May 8 12:26 nginx_1.10.0-0+trusty0_all.deb
-rw-r--r-- 1 root root 3767 May 8 12:26 nginx_1.10.0-0+trusty0_amd64.changes
-rw-r--r-- 1 root root 999933 May 6 04:40 nginx_1.10.0-0+trusty0.debian.tar.gz
-rw-r--r-- 1 root root 2762 May 6 04:40 nginx_1.10.0-0+trusty0.dsc
-rw-r--r-- 1 root root 908954 May 6 04:40 nginx_1.10.0.orig.tar.gz
-rw-r--r-- 1 root root 43544 May 8 12:26 *nginx-common_1.10.0-0+trusty0_all.deb*
-rw-r--r-- 1 root root 35030 May 8 12:26 nginx-doc_1.10.0-0+trusty0_all.deb
-rw-r--r-- 1 root root 639718 May 8 12:26 nginx-extras_1.10.0-0+trusty0_amd64.deb
-rw-r--r-- 1 root root 5902842 May 8 12:26 nginx-extras-dbg_1.10.0-0+trusty0_amd64.deb
-rw-r--r-- 1 root root 3619802 May 8 12:26 *nginx-full_1.10.0-0+trusty0_amd64.deb*
-rw-r--r-- 1 root root 31980276 May 8 12:26 *nginx-full-dbg_1.10.0-0+trusty0_amd64.deb*
-rw-r--r-- 1 root root 329392 May 8 12:26 nginx-light_1.10.0-0+trusty0_amd64.deb
-rw-r--r-- 1 root root 2393308 May 8 12:26 nginx-light-dbg_1.10.0-0+trusty0_amd64.deb
nginx-full_1.10.0-0+trusty0_amd64.deb
nginx-full-dbg_1.10.0-0+trusty0_amd64.deb
因为我使用的 64bit Ubuntu, 所以使用 amd64 version. dbg 是一个调试版本, 所以我们使用另外一个安装包 安装 Nginx:
.deb files appear one level above the nginx-1.10.0-0
directory
cd /opt/data/rebuildnginx
sudo dpkg --install nginx-common_1.10.0-0+trusty0_all.deb
sudo dpkg --install nginx-full_1.6.2-5+trusty0_amd64.deb
如果出现如下错误
coam@coamn:/opt/data/rebuildnginx$ sudo dpkg --install nginx-full_1.10.0-0+trusty0_amd64.deb
(Reading database ... 73928 files and directories currently installed.)
Preparing to unpack nginx-full_1.10.0-0+trusty0_amd64.deb ...
Unpacking nginx-full (1.10.0-0+trusty0) over (1.8.1-1+trusty0) ...
dpkg: error processing archive nginx-full_1.10.0-0+trusty0_amd64.deb (--install):
*trying to overwrite '/usr/share/man/man8/nginx.8.gz', which is also in package nginx-common 1.8.1-1+trusty0*
nginx stop/pre-start, process 22048
Processing triggers for man-db (2.6.7.1-1) ...
Errors were encountered while processing:
nginx-full_1.10.0-0+trusty0_amd64.deb
其中一句提示
trying to overwrite '/usr/share/man/man8/nginx.8.gz', which is also in package nginx-common 1.8.1-1+trusty0
因为本机中已安装 nginx 1.8.1
于是我没有卸载 nginx 而是强制安装 已编译完的 nginx-common_1.10.0-0+trusty0_all.deb
sudo dpkg --install nginx-common_1.10.0-0+trusty0_all.deb
coam@coamn:/opt/data/rebuildnginx$ sudo dpkg --install nginx-full_1.10.0-0+trusty0_amd64.deb
(Reading database ... 73924 files and directories currently installed.)
Preparing to unpack nginx-full_1.10.0-0+trusty0_amd64.deb ...
* Unpacking nginx-full (1.10.0-0+trusty0) over (1.8.1-1+trusty0) ...*
Setting up nginx-full (1.10.0-0+trusty0) ...
nginx stop/pre-start, process 22945
Processing triggers for man-db (2.6.7.1-1) ...
使用 nginx -V
检查已安装的模块
coam@coamn:/opt/data/rebuildnginx$ nginx -V
nginx version: nginx/1.10.0
built with OpenSSL 1.0.2f 28 Jan 2016
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads --add-module=/opt/data/rebuildnginx/nginx-1.10.0/debian/modules/nginx-auth-pam --add-module=/opt/data/rebuildnginx/nginx-1.10.0/debian/modules/nginx-dav-ext-module --add-module=/opt/data/rebuildnginx/nginx-1.10.0/debian/modules/nginx-echo --add-module=/opt/data/rebuildnginx/nginx-1.10.0/debian/modules/nginx-upstream-fair --add-module=/opt/data/rebuildnginx/nginx-1.10.0/debian/modules/ngx_http_substitutions_filter_module --add-module=/opt/pagespeed/ngx_pagespeed-release-1.11.33.1-beta
注意:
升级完 Nginx
到 1.10.0
后 使用 nginx -t
测试配置文件,出现大量如下错误:
invalid directive "spdy_headers_comp": ngx_http_spdy_module was superseded by ngx_http_v2_module
invalid parameter "spdy": ngx_http_spdy_module was superseded by ngx_http_v2_module in /etc/nginx/sites-coam/Mos_SY.SYAM.TEST.conf:500
注释掉
# spdy_headers_comp 5;
修改
# listen 443 ssl spdy;
listen 443 ssl http2;
以上仅安装了 ngx_pagespeed
扩展模块,我们继续安装以下三个模块 ModSecurity
首先安装 ModSecurity
- http://www.modsecurity.org/
- SpiderLabs/ModSecurity
- https://github.com/SpiderLabs/ModSecurity/releases
## sudo git clone https://github.com/SpiderLabs/ModSecurity.git
安装相关依赖
sudo apt install build-essential libpcre3 libpcre3-dev libssl-dev libtool autoconf apache2-prefork-dev libxml2-dev libcurl4-openssl-dev
下载并编译最新版的 Mod_Securite
cd /opt/
# wget https://github.com/SpiderLabs/ModSecurity/archive/v2.9.0.tar.gz
wget https://github.com/SpiderLabs/ModSecurity/releases/download/v2.9.1/modsecurity-2.9.1.tar.gz
tar modsecurity-2.9.1.tar.gz
将Mod_Security编译成一个标准模块,以便Nginx编译成模块
cd /opt//modsecurity-2.9.1/
./autogen.sh
./configure --enable-standalone-module
make
注,出现错误,暂停解决:
configure: looking for Apache module support via DSO through APXS
configure: error: couldn't find APXS
加入模块配置到 /opt/data/rebuildnginx/nginx-1.10.0/debain/rules 中的full段
–add-module=/opt/ModSecurity-2.9.1/nginx/modsecurity
参考
- 备份 nginx 配置文件
cp /etc/nginx/nginx.conf /etc/nginx/sites-available/*.conf /etc/nginx/conf.d/*.conf ~
- 卸载
Nginx
服务组件
sudo apt remove nginx nginx-common nginx-full
安装 Nginx
组件
- 添加官方源
wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
- 添加镜像源地址
/etc/apt/sources.list
deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx
deb http://nginx.org/packages/mainline/ubuntu/ codename nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ codename nginx
codename is a codename of an Ubuntu release:
Version Codename Supported Platforms
12.04 precise x86_64, i386
14.04 trusty x86_64, i386, aarch64/arm64
15.10 wily x86_64, i386
16.04 xenial x86_64, i386
参考 INSTALLING NGINX OPEN SOURCE
- 添加
Nginx
依赖模块
//apt install lua5.1
//apt install liblua5.1-dev
- 添加
https://github.com/simpl/ngx_devel_kit.git
和lua-nginx-module
模块
/opt/data/ngx-m
git clone https://github.com/simpl/ngx_devel_kit.git
git clone https://github.com/openresty/lua-nginx-module.git
git clone https://github.com/openresty/echo-nginx-module.git
获取 ngx_pagespeed
参照以上
- 安装
ngx_pagespeed
依赖:
sudo apt install uuid-dev
添加 --add-module
参照 How to install NGINX with Google PageSpeed module in Ubuntu 14.04 Server
* 获取 ngx_pagespeed
并添加 --add-module=/opt/data/ngx-m/pagespeed/ngx_pagespeed-latest-stable
到
/opt/data/nginx/nginx-1.11.5/debian/rules
config.status.nginx: config.env.nginx
cd $(BUILDDIR_nginx) && \
CFLAGS="" ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt="$(CFLAGS)" --with-ld-opt="$(LDFLAGS)" \
--add-module=/opt/data/ngx-m/ngx_devel_kit --add-module=/opt/data/ngx-m/lua-nginx-module --add-module=/opt/data/ngx-m/echo-nginx-module --add-module=/opt/data/ngx-m/pagespeed/ngx_pagespeed-latest-stable
touch $@
- 开始编译
nginx
- 执行更新命令
sudo apt update
- 创建 nginx 编译目录
cd /opt/data
mkdir nginx
cd nginx
- 获取
nginx
最新源
/opt/data/nginx/
sudo apt install dpkg-dev
apt source nginx // 不加 sudo
Thu Nov 03 13:30:18 coam@coamer:/opt/data/nginx$ ls
nginx-1.11.5 nginx_1.11.5-1~xenial.debian.tar.xz nginx_1.11.5-1~xenial.dsc nginx_1.11.5.orig.tar.gz
- 添加模块到 [/opt/data/nginx/nginx-1.11.5/debian/rules] @[–add-module=/opt/data/ngx-m/ngx_devel_kit –add-module=/opt/data/ngx-m/lua-nginx-module –add-module=/opt/data/ngx-m/echo-nginx-module –add-module=/opt/data/ngx-m/pagespeed/ngx_pagespeed-latest-stable]
/opt/data/nginx/nginx-1.11.5/
sudo apt build-dep nginx
dpkg-buildpackage -b
//dpkg-buildpackage -b -uc -us
- 以上命令将会在
/opt/data/nginx/
下生成如下一个安装文件
sudo dpkg -i nginx_1.11.5-1~xenial_amd64.deb
sudo dpkg -i nginx_1.11.5-1~xenial_i386.deb
我编译完后生成了如下文件,编译它
sudo dpkg -i nginx_1.11.5-1~xenial_amd64.deb
Thu Nov 03 14:28:20 coam@coamer:/opt/data/nginx$ sudo nginx -V
nginx version: nginx/1.11.5
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.2)
built with OpenSSL 1.0.2h 3 May 2016
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' --add-module=/opt/data/ngx-m/pagespeed/ngx_pagespeed-latest-stable
可以看到后面添加了 --add-module=/opt/data/ngx-m/pagespeed/ngx_pagespeed-latest-stable
编译参数
- 如果新添加模块,比如
ngx_devel_kit
下载模块后只需添加到nginx~/debian/rules
后重新编译即可
–add-module=/opt/data/ngx_devel_kit
dpkg-buildpackage -b -uc -us
- 如果以下编译出现错误:
dh_installdirs: problem reading debian/nginx.dirs:
debian/rules:87: recipe for target 'install' failed
make: *** [install] Error 127
dpkg-buildpackage: error: debian/rules binary gave error exit status 2
修改 [sudo apt source nginx] 为 [apt source nginx] * Cannot compile nginx with mod_pagespeed: problem reading debian/nginx-common.dirs
- 如果添加 [–add-module=/opt/data/lua-nginx-module] 出现以下编译错误:
源码编译
lua5.3
编译还是出现如下错误,估计找不到 lua 或
adding module in /opt/data/ngx-m/lua-nginx-module
checking for Lua library ... not found
checking for Lua library in /usr/local/ ... not found
checking for Lua library in /usr/local/ ... not found
checking for Lua library in /usr/pkg/ ... not found
checking for Lua library in /opt/local/ ... not found
checking for Lua library in /usr/local/*/lua51/ ... not found
checking for Lua library in /usr/ ... not found
checking for LuaJIT library in /usr/local/ ... not found
checking for LuaJIT library in /usr/ ... not found
checking for LuaJIT library in /usr/ ... not found
./configure: error: ngx_http_lua_module requires the Lua library.
debian/rules:38: recipe for target 'config.status.nginx' failed
make: *** [config.status.nginx] Error 1
dpkg-buildpackage: error: debian/rules build gave error exit status 2
- 需要安装如下库
sudo apt install libluajit-5.1-dev
启动 Nginx
服务
Now let’s start Nginx.
sudo systemctl start nginx
If you see the following error message.
Failed to start cs-nginx.service: Unit cs-nginx.service is masked. Then unmask nginx and issue the start command again.
sudo systemctl unmask nginx
Note that the Nginx process might run as user nginx or www-data. This can be changed by editing the first line in /etc/nginx/nginx.conf file. Just make sure Nginx run as the same user with PHP-FPM.
Now check the config arguments of Nginx.
sudo nginx -V
If you see the following line at the end then ngx_pagespeed module is successfully added to Nginx.
--add-module=/opt/data/ngx-m/pagespeed/ngx_pagespeed-latest-stable
配置 Nginx 启用 ngx_pagespeed
插件
启用 pagespeed
之前,可以先通过 pingdom.com 或 www.webpagetest.org 测试比对一下
配置 server
新建 /etc/nginx/coam.include.d/common_server_pagespeed.conf
/etc/nginx/coam.include.d/common_server_pagespeed.conf
# enable pagespeed module on this server block
pagespeed on;
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
# pagespeed FileCachePath /var/ngx_pagespeed_cache;
pagespeed FileCachePath /data/home/coam/Server/Run/docs/zz_ngx_ps_cache;
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
pagespeed RewriteLevel CoreFilters;
在 server 段引入即可
server {
...
# Common ngx_pagespeed_cache config
include /etc/nginx/coam.include.d/common_server_pagespeed.conf;
...
}
- 测试
curl -I -p https://wsa.iirii.com| grep X-Page-Speed
Thu Nov 03 07:21:29 coam@coam:~$ curl -I -p https://wsa.iirii.com| grep X-Page-Speed
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:04 --:--:-- 0
X-Page-Speed: 1.11.33.4-0
- 编译安装
LuaJit
依赖库
wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
tar -zxvf LuaJIT-2.0.5.tar.gz
cd LuaJIT-2.0.5
make
sudo make install PREFIX=/usr/local/luajit
- tell nginx’s build system where to find LuaJIT 2.1:
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
- 安装
lua-nginx-module
,添加ngx_devel_kit
和lua-nginx-module
依赖库…
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar -zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
#./configure --with-ld-opt="-Wl,-rpath,/usr/local/luajit/lib"
#./configure --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
./configure --user=nginx --group=nginx --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_body_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-compat --with-file-aio --with-threads --with-mail --with-mail_ssl_module --with-http_stub_status_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_sub_module --with-http_v2_module --with-stream --with-stream_realip_module --with-http_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=/opt/data/ngx-m/ngx_devel_kit --add-module=/opt/data/ngx-m/lua-nginx-module --add-module=/opt/data/ngx-m/echo-nginx-module --add-module=/opt/data/ngx-m/incubator-pagespeed-ngx-latest-stable
make
sudo make install
Comments