Linux,nginx,http,web

nginx编译安装,并以动态加载的方式加入一些第三模块

Compile install nginx and, whith nginx-http-auth-digest, lua-nginx-module, nginx-rtmp-module. Dynamic loading module...

Environment

| software | Version |
| :-: | :-: |
| nginx | 1.16.0 |
| OS | CentOS 7.6 |

preparation

  • Compile Env
yum install -y gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2-devel libxslt-devel perl-ExtUtils-Embed GeoIP-devel gperftools git wget
  • Get source
wget http://nginx.org/download/nginx-1.16.0.tar.gz
  • Get thirdparty module
git clone https://github.com/lushenle/nginx-http-auth-digest.git
git clone https://github.com/openresty/luajit2.git
git clone https://github.com/openresty/lua-nginx-module.git
git clone https://github.com/simplresty/ngx_devel_kit.git
git clone https://github.com/arut/nginx-rtmp-module.git

Compile and install

  • Compile luajit
make && make install

cat <<EOF | tee /etc/profile.d/luajit.sh
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.1
EOF

source /etc/profile.d/luajit.sh
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
  • verification luajit env
luajit -v
  • Compile nginx
groupadd -r -g 80 nginx
useradd -r -s /sbin/nologin -g 80 -u 80 nginx

./configure --prefix=/app/ngx \
--modules-path=/app/ngx/modules \
--conf-path=/app/ngx/nginx.conf \
--error-log-path=/app/ngx/logs/error.log \
--http-log-path=/app/ngx/logs/access.log \
--http-client-body-temp-path=/app/ngx/tmp/client_body \
--http-proxy-temp-path=/app/ngx/tmp/proxy \
--http-fastcgi-temp-path=/app/ngx/tmp/fastcgi \
--http-uwsgi-temp-path=/app/ngx/tmp/uwsgi \
--http-scgi-temp-path=/app/ngx/tmp/scgi \
--pid-path=/app/ngx/run/nginx.pid \
--lock-path=/app/ngx/lock/subsys/nginx \
--user=nginx \
--group=nginx \
--with-file-aio \
--with-http_auth_request_module \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_slice_module \
--with-http_stub_status_module \
--with-http_perl_module=dynamic \
--with-pcre \
--with-pcre-jit \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-google_perftools_module \
--with-debug \
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' \
--with-ld-opt='-Wl,-rpath,/usr/local/lib' \
--add-dynamic-module=/app/software/lua-nginx-module \
--add-dynamic-module=/app/software/nginx-http-auth-digest \
--add-dynamic-module=/app/software/ngx_devel_kit \
--add-dynamic-module=/app/software/nginx-rtmp-module \
--add-dynamic-module=/app/software/echo-nginx-module \
--add-dynamic-module=/app/software/ngx_http_geoip2_module

make && make install
ln -sv /app/ngx/sbin/nginx /usr/sbin/nginx
mkdir -pv /app/ngx/tmp/{client_body,proxy,fastcgi,uwsgi,scgi}
mkdir /app/ngx/lock/subsys -pv
  • verification nginx env
nginx -t
微信扫一扫,向我赞赏

微信扫一扫,向我赞赏

微信扫一扫,向我赞赏

支付宝扫一扫,向我赞赏

回复

This is just a placeholder img.