Nginx|apt-get安装nginx及vts和sts
Posted 雨鸟飞行
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx|apt-get安装nginx及vts和sts相关的知识,希望对你有一定的参考价值。
nginx是一个异步框架的Web服务器,也可以用作反向代理,负载平衡器和HTTP缓存。本文主要演示在ubuntu18.04通过apt安装nginx最新版1.16.1,并启用vts和sts插件.
查看系统
LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
更新apt并安装必备插件
apt-get update
apt install curl gnupg2 ca-certificates lsb-release -y
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
再次更新apt缓存并查看nginx版本
apt update
apt-cache madison nginx
nginx | 1.16.1-1~bionic | http://nginx.org/packages/ubuntu bionic/nginx amd64 Packages
nginx | 1.16.0-1~bionic | http://nginx.org/packages/ubuntu bionic/nginx amd64 Packages
nginx | 1.14.2-1~bionic | http://nginx.org/packages/ubuntu bionic/nginx amd64 Packages
nginx | 1.14.1-1~bionic | http://nginx.org/packages/ubuntu bionic/nginx amd64 Packages
nginx | 1.14.0-1~bionic | http://nginx.org/packages/ubuntu bionic/nginx amd64 Packages
安装指定版本
apt-get install nginx=1.16.1-1~bionic
接下安装统计插件vts和sts
cd /usr/local/src
mkdir nginx
cd nginx
git clone https://github.com/vozlt/nginx-module-vts.git
git clone https://github.com/vozlt/nginx-module-sts.git
git clone https://github.com/vozlt/nginx-module-stream-sts.git
wget http://nginx.org/download/nginx-1.16.1.tar.gz
tar xf nginx-1.16.1.tar.gz
cd nginx-1.16.1
安装编译必备开发库
install -y --no-install-recommends \
libluajit-5.1-dev \
libpam0g-dev \
zlib1g-dev \
libpcre3-dev \
libssl-dev \
libluajit-5.1-dev \
libpam0g-dev \
zlib1g-dev \
libpcre3-dev \
libexpat1-dev \
git curl build-essential
编译
./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-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' \
--with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' \
--add-module=../nginx-module-vts \
--add-module=../nginx-module-sts \
--add-module=../nginx-module-stream-sts
注意add-module指定源码目录
编译
make
替换现有nginx
cp objs/nginx /usr/sbin
重启生效
/etc/init.d/nginx restart
篇幅问题,下篇再演示统计
以上是关于Nginx|apt-get安装nginx及vts和sts的主要内容,如果未能解决你的问题,请参考以下文章