twn39 / code

:memo: 代码笔记,通过 issue 的方式记录日常遇到的问题和学习笔记
13 stars 1 forks source link

Openresty 配置 #89

Open twn39 opened 8 years ago

twn39 commented 8 years ago

Openresty 配置

twn39 commented 8 years ago

从官网下载源代码,解压,编译.如果报PECR 错误,安装PECR 库sudo apt-get install libpcre++-dev。所有的文件默认都放在/usr/local/openresty目录下,文件结构:

.
├── bin
│   └── resty
├── luajit
│   ├── bin
│   ├── include
│   ├── lib
│   └── share
├── lualib
│   ├── cjson.so
│   ├── ngx
│   ├── rds
│   ├── redis
│   └── resty
└── nginx
    ├── client_body_temp
    ├── conf
    ├── fastcgi_temp
    ├── html
    ├── logs
    ├── proxy_temp
    ├── sbin
    ├── scgi_temp
    └── uwsgi_temp

有关于nginx的配置文件都放在nginx目录中:

.
├── client_body_temp [error opening dir]
├── conf
│   ├── conf.d
│   ├── fastcgi.conf
│   ├── fastcgi.conf.default
│   ├── fastcgi_params
│   ├── fastcgi_params.default
│   ├── koi-utf
│   ├── koi-win
│   ├── mime.types
│   ├── mime.types.default
│   ├── nginx.conf
│   ├── nginx.conf.default
│   ├── scgi_params
│   ├── scgi_params.default
│   ├── uwsgi_params
│   ├── uwsgi_params.default
│   └── win-utf
├── fastcgi_temp [error opening dir]
├── html
│   ├── 50x.html
│   └── index.html
├── logs
│   ├── access.log
│   ├── error.log
│   └── nginx.pid
├── proxy_temp [error opening dir]
├── sbin
│   └── nginx
├── scgi_temp [error opening dir]
└── uwsgi_temp [error opening dir]
twn39 commented 8 years ago

可以仿照原版nginx的文件结构,添加conf.dsites-avaliable目录,配置多个server。 启动:

/usr/local/openresty/nginx/sbin/nginx

nginx.conf大致的配置:

user  www-data;
worker_processes  auto;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    tcp_nopush     on;

    keepalive_timeout  65;

    gzip  on;

    include /usr/local/openresty/nginx/conf/conf.d/*.conf;
}