所需环境
安装 Tengine 需要:pcre、openssl、zlib 源码。自行下载。
操作系统:Alpine
Tengine 版本:2.3.1
Tengine 安装
运行用户:www
日志目录:/var/log/Tengine
临时目录:/var/tmp/Tengine
./configure --prefix=/usr/local/Tengine --pid-path=/var/run/nginx.pid --group=www --user=www --with-poll_module --without-select_module --with-threads --with-http_v2_module --add-module=./modules/ngx_http_concat_module --with-http_realip_module --with-http_image_filter_module --add-module=./modules/ngx_http_lua_module --with-lua-inc=/usr/local/include --with-lua-lib=/usr/local/lib --with-luajit-inc=/usr/local/include/luajit-2.0 --with-luajit-lib=/usr/local/lib --with-pcre=/data/source/tengine/pcre-8.42 --with-zlib=/data/source/tengine/zlib-1.2.11 --with-openssl=/data/source/tengine/openssl-1.1.1c --http-proxy-temp-path=/var/tmp/Tengine/proxy_temp --http-fastcgi-temp-path=/var/tmp/Tengine/fastcgi_temp --http-uwsgi-temp-path=/var/tmp/Tengine/uwsgi_temp --http-scgi-temp-path=/var/tmp/Tengine/cgi_temp --http-client-body-temp-path=/var/tmp/Tengine/client_body_temp --http-log-path=/var/log/Tengine/access.log --error-log-path=/var/log/Tengine/error.log
Tengine 配置
user www www;
worker_processes xx; # CPU 个数即可
worker_cpu_affinity xxxx; # 参考 http://nginx.org/en/docs/ngx_core_module.html#worker_cpu_affinity
error_log /var/log/Tengine/error.log;
pid /var/run/nginx.pid;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type text/html;
charset UTF-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
client_max_body_size 10M; # 该值需要大于最大允许上传文件大小的值
# 开启 css、js 合并 #
concat on;
concat_max_files 20;
concat_unique on;
concat_delimiter "\r\n";
concat_ignore_file_error on;
# 开启 GZIP 压缩 #
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_vary on;
gzip_types text/plain text/css text/javascript application/x-javascript application/javascript text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml application/xml-dtd;
proxy_connect_timeout 60;
proxy_read_timeout 60;
proxy_send_timeout 30;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_temp_path /var/tmp/Tengine/proxy_temp_dir;
proxy_cache_path /var/tmp/Tengine/proxy_cache levels=1:2 keys_zone=key:2m inactive=1d max_size=1g;
ssi on;
ssi_silent_errors off;
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/Tengine/access.log access;
include "upstream.conf";
include "vhosts.conf";
}