=============編譯安裝=========
wget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz
tar -zxvf tengine-2.1.2.tar.gz
cd tengine-2.1.2 javascript
yum -y install pcre-devel openssl-devel gd-devel css
./configure --prefix=/data/tengine --with-cc-opt='-O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-file-aio --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_secure_link_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-ld-opt=-Wl,-E --with-pcrejava
make
make installnode
編輯配置文件
vim /data/tengine/conf/nginx.confnginx
worker_processes auto;
worker_cpu_affinity auto;
worker_rlimit_nofile 65535;算法
events {
use epoll;
multi_accept on;
worker_connections 65535;
}vim
http {
include mime.types;
default_type application/octet-stream;
charset utf-8;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent $request_time "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$proxy_add_x_forwarded_for" "$upstream_response_time" ';後端
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 64k;
client_max_body_size 8m;
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;服務器
server {
listen 8880;
server_name 127.0.0.1;
location ~ ^/NginxStatus {
stub_status on;
access_log off;
}
}
include /data/tengine/conf.d/*.conf;
include /data/tengine/upstream.conf.d/*.conf;
}cookie
編輯配置文件:
/data/tengine/conf.d/*.conf;
/data/tengine/upstream.conf.d/*.conf;
啓動
/data/tengine/sbin/nginx -t #語法測試
/data/tengine/sbin/nginx 啓動
tengine命令行參數
-m 選項:顯示全部編譯的模塊,Tengine支持動態模塊,static表示靜態編譯,shared表示動態編譯(後面接的是動態模塊的版本)
'-l' 選項: 顯示全部支持的指令
'-d' 選項: 輸出配置文件的內容,包括'include'的內容
[root@10-9-58-137 ~]# /data/tengine/sbin/nginx -V #注意是大寫的V ,小寫的v只顯示版本信息 Tengine version: Tengine/2.1.2 (nginx/1.6.2) built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) TLS SNI support enabled configure arguments: --prefix=/data/tengine --with-cc-opt='-O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-file-aio --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_secure_link_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-ld-opt=-Wl,-E --with-pcre loaded modules: ngx_core_module (static) ngx_errlog_module (static) .......省略中間的模塊...... ngx_http_upstream_ip_hash_module (static) ngx_http_upstream_consistent_hash_module (static) #該模塊是一個負載均衡器,使用一個內部一致性hash算法來選擇合適的後端節點 ngx_http_upstream_check_module (static) #該模塊能夠爲Tengine提供主動式後端服務器健康檢查的功能。 ngx_http_upstream_session_sticky_module (static) #該模塊是一個負載均衡模塊,經過cookie實現客戶端與後端服務器的會話保持, 在必定條件下能夠保證同一個客戶端訪問的都是同一個後端服務器 ngx_http_stub_status_module (static) #stub_status模塊主要用於查看Nginx的一些狀態信息 ngx_http_stub_status_module 增長對每請求的響應時間的統計:在stub status模塊中增長了自Tengine啓動以來全部請求的總響應時間(request_time),單位爲ms,能夠用來統計一段時間的平均RT(response time): Active connections: 1 server accepts handled requests request_time 1140 1140 1140 75806 Reading: 0 Writing: 1 Waiting: 0