zoukankan      html  css  js  c++  java
  • OpenResty

    OpenResty的现状、趋势、使用及学习方法

     

     

    [root@slave-2 ~]# cat /etc/centos-release

    CentOS Linux release 7.4.1708 (Core) 

    [root@slave-2 ~]# uname -r

    3.10.0-693.el7.x86_64

     

     

     

    OpenResty安装

    #yum方式安装

     

    1.依赖包安装:

     

       # yum -y install readline-devel pcre-devel openssl-devel yum-utils

     

    2.在系统中添加openresty的仓库:

     

       # yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

     

    3.开始安装openresty

     

       # yum -y install openresty openresty-resty

     

    4.以上安装完成后Openresty就安装完成了,默认安装目录在/usr/local/openresty下

     

    #源码方式安装

    下载:http://openresty.org/cn/download.html

    安装:http://openresty.org/cn/installation.html

    #安装依赖

    yum -y install libpcre3-dev libssl-dev perl make build-essential curl gcc-c++ c++ pcre* openssl*

    #下载源码包

    wget https://openresty.org/download/openresty-1.15.8.1.tar.gz

    tar -zxvf openresty-1.15.8.1.tar.gz

    cd openresty-1.15.8.1

    ./configure --with-pcre && make && make install

     

     

     

    groupadd nginx

    useradd -g nginx -s /sbin/nologin -M nginx

     

     

    OpenResty的nginx配置

    vim /usr/local/openresty/nginx/conf/nginx.conf

    user nxinx nginx;         #启动用户

    worker_processes 1;    #nginx的进程数,建议和cpu的核数一致

     

    error_log  logs/error.log;  #全局log定义

    #error_log  logs/error.log  notice;

    #error_log  logs/error.log  info;

     

    pid        logs/nginx.pid;  #进程文件ID

     

    worker_rlimit_nofile 65535;  #nginx进程打开的文件数

     

    #工作模式和连接数设置

    events {

        use epoll;          #epoll是高版本内核优化后的网络I/O模型,默认没有该选项

        worker_connections 65535; #单个进程最大的连接数

        multi_accept on;      #打开快速接收新连接,默认没有该选项

    }

     

    #http服务设置

    http {

        include       mime.types;  #文件扩展名和类型映射表

        default_type  application/octet-stream;  #默认文件类型

        charset utf-8;  #默认编码

        server_names_hash_bucket_size 128;      #服务器名字的hash表大小

        client_header_buffer_size 32k;          #上传文件大小限制

        large_client_header_buffers 4 32k;      #设定请求缓存数

        client_max_body_size 32m;       #设定请求缓存大小

     

        sendfile on;    #开启高效文件传输

        tcp_nopush on;  #防止网络阻塞

        tcp_nodelay on;

     

       keepalive_timeout  65;    #长连接超时时间,默认单位为

     

    #以下是FastCGI 的相关参数,主要作用减少资源占用优化网站性能提高访问速度

    fastcgi_connect_timeout 300;

    fastcgi_send_timeout 300;

    fastcgi_read_timeout 300;

    fastcgi_buffer_size 64k;

    fastcgi_buffers 4 64k;

    fastcgi_busy_buffers_size 128k;

    fastcgi_temp_file_write_size 64k;

        open_file_cache max=10240 inactive=20s;

        open_file_cache_min_uses 1;

        open_file_cache_valid 30s;

     

     

    #gizp优化配置,加速传速

    gzip on;

    gzip_min_length 1k;

    gzip_buffers 4 16k;

    gzip_http_version 1.0;

    gzip_comp_level 2;

    gzip_types text/plain application/x-javascript text/css application/xml;

    gzip_vary on;

    gzip_disable msie6;

     

    lua_package_path "/usr/local/openresty/nginx/lua/?.lua;;";   #需要用到lua的项目脚本设用路径

     

    启动命令:

    对配置文件进行更改后我们再启动时先检查配置文件的语法是否正确:

    # openresty  –t

     

    {启动|重新载入|停止」nginx:

    # openresty

    # openresty -s reload

    # openresty -s stop

     

    如果在启动时出现以下报错:

    nginx: [error] invalid PID number "" in "/usr/local/openresty/nginx/logs/nginx.pid"

    那我们就需要重新定义一下nginx.conf的指定

    # /usr/local/openresty/nginx/sbin/nginx  -c  /usr/local/openresty/nginx/conf/nginx.conf

     

     

                    QQ群:264092835   欢迎你的加入

     

     

     

    以上信息源出处

     

     

     

     

     

     

  • 相关阅读:
    Gradle 10分钟上手指南
    java并发编程学习: 原子变量(CAS)
    java并发编程学习: 守护线程(Daemon Thread)
    java并发编程学习: 阻塞队列 使用 及 实现原理
    java并发编程学习: ThreadLocal使用及原理
    java并发编程学习:如何等待多个线程执行完成后再继续后续处理(synchronized、join、FutureTask、CyclicBarrier)
    ZooKeeper 笔记(5) ACL(Access Control List)访问控制列表
    gradle项目与maven项目相互转化
    rpc框架之 thrift连接池实现
    java并发编程学习:用 Semaphore (信号量)控制并发资源
  • 原文地址:https://www.cnblogs.com/smlile-you-me/p/11205953.html
Copyright © 2011-2022 走看看