ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
> `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/)