返回顶部

openresty编译安装

openresty编译安装

Nginx 是俄罗斯人发明的, Lua 是巴西几个教授发明的,中国人章亦春把 LuaJIT VM 嵌入到 Nginx中,实现了 OpenResty 这个高性能服务端解决方案

OpenResty® 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。

OpenResty® 的目标是让你的Web服务直接跑在 Nginx 服务内部,充分利用 Nginx 的非阻塞 I/O 模型,不仅仅对HTTP 客户端请求,甚至于对远程后端诸如 MySQL、PostgreSQL、Memcached 以及Redis 等都进行一致的高性能响应。

官网: http://openresty.org/cn/

#cat nginx.sh
#!/bin/bash
#********************************************************************
#Author:        wei
#********************************************************************
yum_package () {
yum install -y pcre-devel openssl-devel gcc curl make
}

make_nginx () {
cd /usr/local/
wget https://openresty.org/download/openresty-1.17.8.2.tar.gz
cd /usr/local/
tar -zxvf openresty-1.17.8.2.tar.gz
cd /usr/local/
mv openresty-1.17.8.2 openresty
cd /usr/local/openresty/
 ./configure --with-luajit \
            --without-http_redis2_module \
            --with-http_iconv_module \
            --with-http_sub_module
cd /usr/local/openresty/
make && make install

#添加nginx环境变量
echo 'export PATH=/usr/local/openresty/nginx/sbin:$PATH'  >> /etc/profile
source /etc/profile
nginx -V
}
nginx_conf () {
cat <<EOF  > /usr/local/openresty/nginx/conf/nginx.conf

nginx.conf
user root;
worker_processes auto;
events {
use epoll;
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/xiaowangCookie.log main;
sendfile on;
keepalive_timeout 65;
gzip on; # 默认off,是否开启gzip
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rsstext/javascript;
proxy_connect_timeout 5;
#跟后端服务器连接的超时时间_发起握⼿等候响应超时时间
proxy_read_timeout 5;
#连接成功后_等候后端服务器响应的时间_其实已经进⼊后端的排队之中等候处理
proxy_send_timeout 5;
#后端服务器数据回传时间_就是在规定时间内后端服务器必须传完所有数据
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
server{
listen 8012;
server_name localhost;
location / {
proxy_pass https://etax.guangdong.chinatax.gov.cn/;
}
location /api/v1.0/auth/oauth2/interfaceHideLogin {
proxy_pass https://tpass.guangdong.chinatax.gov.cn:8443;
}
}
server{
listen 8013;
server_name localhost;
location / {
proxy_pass https://etax.jiangsu.chinatax.gov.cn/;
}
}
server{
listen 8014;
server_name localhost;
location / {
proxy_pass https://etax.hebei.chinatax.gov.cn/;
}
}
server{
listen 8015;
server_name localhost;
location / {
proxy_pass https://etax.shandong.chinatax.gov.cn/;
}
}
server{
listen 8040;
server_name localhost;
location / {
proxy_pass https://fpdk.anhui.chinatax.gov.cn/;
}
}
server{
listen 8016;
server_name localhost;
location / {
proxy_pass https://etax.anhui.chinatax.gov.cn/;
}
location = /cas/oauth2/callback {
proxy_pass https://etax.anhui.chinatax.gov.cn/cas/oauth2/callback;
}
}
server{
listen 8017;
server_name localhost;
location / {
proxy_pass https://etax.zhejiang.chinatax.gov.cn/;
}
}
server{
listen 8018;
server_name localhost;
location / {
proxy_pass https://etax.hunan.chinatax.gov.cn/;
}
}
server{
listen 8019;
server_name localhost;
location / {
proxy_pass https://etax.tianjin.chinatax.gov.cn//;
}
}
server{
listen 8020;
server_name localhost;
location / {
proxy_pass https://etax.shanghai.chinatax.gov.cn//;
}
}
server{
listen 8021;
server_name localhost;
location / {
proxy_pass https://etax.beijing.chinatax.gov.cn//;
}
}
server{
listen 8022;
server_name localhost;
location / {
proxy_pass https://etax.hubei.chinatax.gov.cn/;
proxy_set_header Host :; #
}
}
server{
listen 8023;
server_name localhost;
location / {
proxy_pass https://etax.shenzhen.chinatax.gov.cn//;
}
}
server{
listen 8024;
server_name localhost;
location / {
proxy_pass https://etax.xiamen.chinatax.gov.cn/;
}
}
server{
listen 8025;
server_name localhost;
location / {
proxy_pass https://etax.qingdao.chinatax.gov.cn:7553/;
}
}
server{
listen 8026;
server_name localhost;
location / {
proxy_pass https://etax.guangxi.chinatax.gov.cn:9723;
}
}
server{
listen 8027;
server_name localhost;
location / {
proxy_pass https://etax.guizhou.chinatax.gov.cn/;
}
}
server{
listen 8028;
server_name localhost;
location / {
proxy_pass https://etax.fujian.chinatax.gov.cn/;
}
}
server{
listen 8029;
server_name localhost;
location / {
proxy_pass https://etax.ningbo.chinatax.gov.cn/;
}
}
server{
listen 8030;
server_name localhost;
location / {
proxy_pass https://etax.chongqing.chinatax.gov.cn/;
}
}
}


EOF

nginx -t  && nginx  && echo -e '\033[44;32mnginx启动成功\033[0m'
}

yum_package
make_nginx
nginx_conf

官方链接:http://openresty.org/cn/

 

posted @ 2022-08-05 22:49  九尾cat  阅读(301)  评论(0编辑  收藏  举报