> `nginx -V` 查看編譯參數命令;
```
$ /usr/local/openresty/nginx/sbin/nginx -V
nginx version: openresty/1.13.6.1
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
built with OpenSSL 1.0.2j 26 Sep 2016
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx
--with-debug
--with-cc-opt='-DNGX_LUA_USE_ASSERT -DNGX_LUA_ABORT_AT_PANIC -O2 -O3'
--add-module=../ngx_devel_kit-0.3.0
--add-module=../iconv-nginx-module-0.14
--add-module=../echo-nginx-module-0.61
--add-module=../xss-nginx-module-0.05
--add-module=../ngx_coolkit-0.2rc3
--add-module=../set-misc-nginx-module-0.31
--add-module=../form-input-nginx-module-0.12
--add-module=../encrypted-session-nginx-module-0.07
--add-module=../srcache-nginx-module-0.31
--add-module=../ngx_lua-0.10.11
--add-module=../ngx_lua_upstream-0.07
--add-module=../headers-more-nginx-module-0.33
--add-module=../array-var-nginx-module-0.05
--add-module=../memc-nginx-module-0.18
--add-module=../redis-nginx-module-0.3.7
--add-module=../rds-json-nginx-module-0.15
--add-module=../rds-csv-nginx-module-0.08
--add-module=../ngx_stream_lua-0.0.3
--with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib
--user=www
--group=www
--with-file-aio
--with-threads
--with-http_v2_module
--with-http_realip_module
--with-http_mp4_module
--with-stream
--with-http_gzip_static_module
--with-http_ssl_module
--with-openssl=/usr/local/ssl
--with-openssl-opt=enable-tlsext
--with-http_stub_status_module
--with-http_xslt_module
--add-dynamic-module=/home/www/build/nginx-ts-module
--add-dynamic-module=/home/www/build/nginx-rtmp-module
--add-dynamic-module=/home/www/build/nginx-module-vts
--add-module=/home/www/build/ngx_cache_purge-2.3
--add-dynamic-module=/home/www/build/nginx-vod-module
--add-dynamic-module=/home/www/build/nginx-push-stream-module
--with-stream --with-stream_ssl_module
```
> `--with` 的編譯參數特別說明(代表官網模塊)
> 安裝編譯參數詳解
```
--prefix=/etc/nginx #nginx的主目錄;
--sbin-path=/usr/sbin/nginx #nginx的執行命令目錄;
--modules-path=/usr/lib64/nginx/modules #nginx的模塊目錄;
--conf-path=/etc/nginx/nginx.conf #nginx的配置文件目錄;
--error-log-path=/var/log/nginx/error.log #nginx的錯誤日志目錄;
--http-log-path=/var/log/nginx/access.log #nginx的訪問日志目錄;
--pid-path=/var/run/nginx.pid #nginx的pid進程文件路徑;
--lock-path=/var/run/nginx.lock #Nginx鎖文件目錄;
// 執行對應模塊時,Nginx所保留的臨時性文件;帶有temp后綴字樣的文件;
--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
// 處于服務器安全性的考慮,設定Nginx進程啟動的用戶和組用戶;不建議使用root用戶;
--user=nginx
--group=nginx
--with-cc-opt=parameters #設置額外的參數將被添加到CFLAGS變量;
--with-ld-opt=parameters #設置附加的參數,鏈接系統庫,如pcre庫;
```
> Openresty 編譯參數
```
./configure
--prefix=/usr/local/openresty
--with-luajit
--with-stream
--with-stream_ssl_module
--with-stream=dynamic
--with-file-aio
--with-threads
--with-http_v2_module
--with-http_realip_module
--with-http_mp4_module
--with-http_gzip_static_module
--with-http_ssl_module
--with-http_stub_status_module
--with-http_xslt_module
--with-http_iconv_module
--without-http_redis2_module
--with-openssl-opt=enable-tlsext
--add-dynamic-module=/www/home/nginx-rtmp-module-1.2.1/
--add-dynamic-module=/www/home/nginx-ts-module-0.1.1/
--add-dynamic-module=/www/home/nginx-vod-module-1.23/
--add-dynamic-module=/www/home/nginx-module-vts-0.1.18
```
直接賦值編譯
```
sudo ./configure --prefix=/usr/local/openresty --with-luajit --with-stream --with-stream_ssl_module --with-stream=dynamic --with-file-aio --with-threads --with-http_v2_module --with-http_realip_module --with-http_mp4_module --with-http_gzip_static_module --with-http_ssl_module --with-http_stub_status_module --with-http_xslt_module --with-http_iconv_module --without-http_redis2_module --with-openssl-opt=enable-tlsext --add-dynamic-module=/home/www/nginx-rtmp-module-1.2.1/ --add-dynamic-module=/home/www/nginx-ts-module-0.1.1/ --add-dynamic-module=/home/www/nginx-vod-module-1.23/ --add-dynamic-module=/home/www/nginx-module-vts-0.1.18/
```
> 模塊在www用戶家目錄中
[如何編譯一個高性能 OpenResty](https://yq.aliyun.com/articles/228399)
遇到的問題
```
Starting A dynamic web platform based on Nginx and LuaJIT....
openresty.service: Can't open PID file /run/openresty.pid (yet?) after start: No such file or directory
```
該文件確實存在于`/var/run/openresty.pid`中,并且可讀。更改`/usr/local/openresty/nginx/nginx.conf`:
修改
```
pid /var/run/nginx.pid;
```
為
```
pid /run/openresty.pid;
```
* [nginx服務器安裝及配置文件詳解](http://seanlook.com/2015/05/17/nginx-install-and-config/)
- 序言
- Nginx從入門到實踐
- 第一章 前言
- 第二章 基礎篇
- 2-1 什么是Nginx?
- 2-2 常見的中間件服務
- 2-3 Nginx特性-多路復用
- 2-4 Nginx特性-輕量級
- 2-5 Nginx特性-Cpu親和
- 2-6 Nginx特性_實現優點4
- 2-7 Nginx的快速安裝
- 2-8 Nginx安裝目錄
- 2-9 Nginx編譯配置參數
- 2-10 Nginx默認配置語法
- 2-11 Nginx默認站點啟動
- 2-12 HTTP請求
- 2-13 Nginx日志
- 2-14 Nginx模塊介紹
- 2-15 Nginx的請求限制
- 2-16 Nginx的訪問控制
- 第三章 場景實踐篇
- 3-1 Nginx作為靜態資源web服務
- 1、靜態資源類型
- 2、CDN場景
- 3、配置語法
- 4、場景演示
- 5、瀏覽器緩存原理
- 6、跨站訪問
- 7、防盜鏈
- 3-2 Nginx作為代理服務
- 1、代理服務.
- 2、反向代理配置場景
- 3、正向代理配置場景
- 4、代理配置和規范
- 3-3 Nginx作為負載均衡服務
- 1、配置語法與場景
- 2、參數講解
- 3、backup狀態演示
- 4、輪詢策略
- 3-4 Nginx作為緩存服務
- 1、緩存服務配置語法
- 2、場景配置演示.
- 3、分片請求
- 第四章 深度學習篇
- 4-1 Nginx動靜分離
- 4-2 Rewrite規則
- 1、配置語法
- 2、正則表達式
- 3、規則中的flag
- 4、redirect和permanent區別
- 5、規則場景
- 4-3 Nginx進階高級模塊
- 1、secure_link模塊作用原理
- 2、Geoip讀取地域信息模塊
- 4-4 基于Nginx的HTTPS服務
- 1、原理和作用
- 2、證書簽名生成CA證書.
- 3、實戰場景配置蘋果要求的openssl
- 4、HTTPS服務優化
- 4-5 Nginx與Lua的開發
- 1、Nginx與Lua特性與優勢
- 2、Lua基礎開發語法
- 3、Lua的指令及api接口
- 4、實戰場景灰度發布
- 第五章 Nginx架構篇
- 安全
- 5-27 Nginx+LUA防火墻功能
- Nginx 錯誤專題
- 1、 Failed to parse PID from file
- 2、error: the HTTP gzip module requires the zlib library
- 3、open() “/usr/local/nginx/html/favicon.ico” failed (2: No such file or directory)
- Openresty
- 控制命令