Tengine + Luajit2

系统账号及环境配置

$ sudo useradd -g 100 -u 200 user_00
$ sudo groupadd -g 300 www
$ sudo useradd -g 300 -u 300 -s /sbin/nologin www
$ sudo mkdir -p /usr/local/services/src
$ sudo chown -R user_00.usrs /usr/local/services
$ su - user_00
$ cd /usr/local/services/src

LuaJIT部署

$ wget http://luajit.org/download/LuaJIT-2.1.0-beta2.tar.gz
$ tar xf LuaJIT-2.1.0-beta1.tar.gz
$ cd LuaJIT-2.1.0-beta1
$ make PREFIX=/usr/local/services
$ make install PREFIX=/usr/local/services
$ echo "/usr/local/services/lib" |sudo tee -a /etc/ld.so.conf
$ sudo ldconfig

Tengine 部署

$ wget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz
$ wget ftp://ftp.lanet.lv/pub/unix/security/libmd5-0.8.2b.tar.gz
$ wget https://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.gz/download
$ wget https://www.openssl.org/source/openssl-1.0.2j.tar.gz
$ ./configure \
--prefix=/usr/local/services/tengine-2.1.2 \
--user=www \
--group=www \
--with-http_ssl_module \
--with-http_lua_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-sha1=/usr \
--with-openssl=/usr/local/services/src/openssl-1.0.2j \
--with-md5=/usr/local/services/src/md5 \
--with-pcre=/usr/local/services/src/pcre-8.39 \
--with-luajit-inc=/usr/local/services/include/luajit-2.1 \
--with-luajit-lib=/usr/local/services/lib \
--without-select_module --without-poll_module \
--without-http_userid_module \
--without-mail_pop3_module \
--without-mail_imap_module >/dev/null
$ make >/dev/null && make install >/dev/null
 
$ cd /usr/local/services/tengine-2.1.2
$ mkdir {temp,conf/sites-{available,enabled}}
$ sudo chown www.www temp

Tengine 主配置文件

$ cd /usr/local/services/tengine-2.1.2/conf
$ cat nginx.conf
user www www;
worker_processes 2;
worker_cpu_affinity auto;
pid        logs/nginx.pid;
error_log  logs/error.log  error;
#Specifies the value for maximum file descriptors that can be opened by this process.
events {
    use epoll;
    worker_connections  102400;
}
worker_rlimit_nofile 102400;
http {
    include       mime.types;
    server_info   off;
    server_tokens off;
    server_tag    off;
    default_type  application/octet-stream;
    real_ip_header X-Forwarded-For;
    set_real_ip_from 172.31.0.0/16;
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" $request_time $upstream_response_time $host';
    server_names_hash_bucket_size 256;
    client_header_buffer_size 256k;
    large_client_header_buffers 8 128k;
    client_max_body_size    8m;
    sendfile          on;
    tcp_nopush        on;
    tcp_nodelay       on;
    keepalive_timeout 60;
    proxy_connect_timeout 100s;
    proxy_read_timeout 300;
    proxy_send_timeout 300;
    proxy_buffer_size 512k;
    proxy_buffers  16 256k;
    proxy_busy_buffers_size 512k;
    proxy_temp_file_write_size 512k;
    proxy_ignore_client_abort on;
    gzip              on;
    gzip_min_length   1k;
    gzip_buffers      4 16k;
    gzip_http_version 1.0;
    gzip_comp_level   2;
    gzip_types        text/plain application/javascript application/x-javascript text/css application/xml text/javascript;
    gzip_vary         on;
    charset           utf-8;
    access_log        logs/access.log main;
    log_not_found     off;
    ssi               on;
    ssi_silent_errors on;
    ssi_types         text/shtml;
    fastcgi_temp_path     temp/fastcgi_temp;
    client_body_temp_path temp/client_body_temp;
    proxy_temp_path       temp/proxy_temp;
    scgi_temp_path        temp/scgi_temp;
    uwsgi_temp_path       temp/uwsgi_temp;
    #error_page  500 502 503 504      /50x.html;
    #error_page  400 403 405 408 404  /40x.html;
    req_status_zone server "$host" 256M;
    req_status_zone_add_indicator server $limit;
    upstream appname {
        server 127.0.0.1:8000     weight=1;
        server 127.0.0.2:8000     weight=1;
        keepalive 600;
        check interval=5000 rise=2 fall=5 timeout=1000 type=http;
        check_keepalive_requests 100;
        check_http_send "HEAD / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n";
        check_http_expect_alive http_2xx http_3xx;
    }
    server {
        listen       80 default;
        server_name  _;
        return       444;
        access_log   off;
    }
include sites-enabled/*.conf;
}

Tomcat 动静分离

$ cd /usr/local/services/tengine-2.1.2/conf/sites-available
$ cat www.soa.com.conf
server {
    listen      80;
    server_name www.soa.com;
    root        /data/apps/soa/appname;
    req_status  server;
 
    location / {
        index index.html index.jsp;
        try_files $uri $uri/ @proxy;
    }
 
    location @proxy {
        proxy_pass http://appname;
    }
 
    location ~ \.jsp$ {
        proxy_redirect off;
        proxy_pass http://www.esearchapi.com;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
 
    location ~ .*\.(js|css)?$ {
        expires      12h;
    }
 
    location ~ .*\.(gif|jpg|jpeg|png|bmp)$ {
        expires      1d;
    }
}

Tengine 运行状态,用于监控

$ cd /usr/local/services/tengine-2.1.2/conf/sites-available
$ cat 127.0.0.1.conf
server {
    listen          80;
    server_name     127.0.0.1;
    access_log      off;
 
    set $limit 0;
    if ($arg_limit = '1') { set $limit 1; }
 
    location /stats {
        stub_status on;
    }  
 
    location /upstream_stats {
        check_status;
    }  
 
    location /request_stats {
        req_status_show;
        req_status_show_field req_total conn_total bytes_in bytes_out rt
        http_200 http_404 http_403 http_500 http_502 http_503 http_504
        http_2xx http_3xx http_4xx http_5xx http_other_status $limit;
    }  
}

Nginx 部署及配置的更多相关文章

  1. linux下nginx部署以及配置详解

    1.下载源码包解压编译 启动多个,请看:在linux系统下安装两个nginx以及启动 查看nginx包路径:http://nginx.org/download/,两种下载方式: 1.在官网下载使用Xf ...

  2. Nginx 部署、反向代理配置、负载均衡

    Nginx 部署.反向代理配置.负载均衡 最近我们的angular项目部署,我们采用的的是Nginx,下面对Nginx做一个简单的介绍. 为什么选择Nginx 轻:相比于Apache,同样的web服务 ...

  3. 菜鸟nginx源代码剖析 配置与部署篇(一) 手把手实现nginx "I love you"

    菜鸟nginx源代码剖析 配置与部署篇(一) 手把手配置nginx "I love you" Author:Echo Chen(陈斌) Email:chenb19870707@gm ...

  4. Linux中Nginx服务器的部署和配置

    目录 Nginx安装方式: yum源安装 目录结构: 源码包安装 目录结构: Nginx中支持PHP Nginx中配置php对mysql数据库的支持 Nginx配置反向代理服务器 正常代理 根据不同端 ...

  5. 使用nginx部署Django静态文件配置

    首先,我们配置静态文件,要在setting.py里面加入如下几行代码: # settings.py # the settings above # STATIC SETTINGS STATIC_URL ...

  6. Tomcat服务部署与Nginx负载均衡配置

    一.中间键产品介绍 目前来说IBM的WebSphere,Oracle的Weblogic占据了市场上java语言Web站点的部分份额,该两种软件都是商业化的软件,由于性能优越,可靠性高等优点应用于大型互 ...

  7. Nginx部署vue项目的配置

    . 官网下载 http://nginx.org/en/download.html 选择stable version nginx/Windows-1.14.1 pgp . 解压 然后配置环境变量,如果环 ...

  8. CentOS Mono Nginx 部署 MVC4+WebApi

    CentOS Mono Nginx 部署 MVC4+WebApi 经过几天的折磨,终于在CentOS上成功部署了MVC4+WebApi.Mono上的服务器推荐两种:Jexus(国产高人写的一款很牛的服 ...

  9. windows下nginx安装、配置与使用(转载)

    目前国内各大门户网站已经部署了Nginx,如新浪.网易.腾讯等:国内几个重要的视频分享网站也部署了Nginx,如六房间.酷6等.新近发现Nginx 技术在国内日趋火热,越来越多的网站开始部署Nginx ...

随机推荐

  1. Java 中的四种权限修饰符

    * * private: * Java语言中对访问权限限制的最窄的修饰符,一般称之为“私有的”. * 被其修饰的属性以及方法只能被该类的对象 访问,其子类不能访问,更不能允许跨包访问. * * def ...

  2. 一起来学习XPATH,来看看除了正则表达式我们还能怎么抓取数据

    参考学习的网站链接http://www.w3school.com.cn/xpath/xpath_intro.asp 首先理清楚一些常识 以此为例 <?xml version="1.0& ...

  3. 「 从0到1学习微服务SpringCloud 」04服务消费者Ribbon+RestTemplate

    系列文章(更新ing): 「 从0到1学习微服务SpringCloud 」01 一起来学呀! 「 从0到1学习微服务SpringCloud 」02 Eureka服务注册与发现 「 从0到1学习微服务S ...

  4. 【JQ】 validate验证表单时多个name相同的元素的解决办法

    使用jQuery.validate插件http://jqueryvalidation.org/,当节点的name相同时候,脚本特意忽略剩余节点,导致所有相关节点的errMsg都显示在第一个相关节点上. ...

  5. 小白学Java:File类

    目录 小白学Java:File类 不同风格的分隔符 绝对与相对路径 File类常用方法 常用构造器 创建方法 判断方法 获取方法 命名方法 删除方法 小白学Java:File类 我们可以知道,存储在程 ...

  6. Ninja构建系统入门

    1. 介绍 开篇先介绍.先甩资料给大家看,之后再自己演示一下基本使用.Ninja 是Google的一名程序员推出的注重速度的构建工具,一般在Unix/Linux上的程序通过make/makefile来 ...

  7. 线性最长cover(无讲解)

    #include<bits/stdc++.h> using namespace std; ; int n,f[maxn],cover[maxn],R[maxn]; char str[max ...

  8. hash算法与拉链法解决冲突

    <?php class HashNode { public $key; public $value; public $nextNode; public function __construct( ...

  9. RocketMQ消息模型

    rocketmq采用的是发布-订阅的模式,不需要每个消费者维护自己的消息队列,生产者将消息发送到topic,消费者订阅此topic 读取消息. 基本概念: 消息模型:消息模型包括producer,co ...

  10. Shell常用命令之主机检测(ping)

    主机检测命令ping 向网络主机发送ICMP回传请求 常用选项 -A:洪水攻击选项,启用此功能能在短时间之内发送大量的ping包 -b:开启ping网桥模式,默认不允许ping网桥 -c:设置发送多少 ...