nginx

作者: linson0116 | 来源:发表于2019-01-18 13:54 被阅读0次
    命令 内容 参数 备注
    tar -zxvf xxx.tar.gz 解压文件 -zxvf

    参考

    1. 安装依赖库gcc等
    • yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
    1. 下载 pcre
    1. 编译 pcre
    • tar zxvf pcre-8.35.tar.gz
    • cd pcre-8.35
    • ./configure
    • make && make install
    • pcre-config --version
    1. 下载 nginx
    1. 编译 nginx
    • mkdir /usr/local/webserver
    • cd /usr/local/webserver/
    • mkdir nginx
    • cd /usr/local/src/nginx-1.6.2
    • ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
    • make && make install
    • /usr/local/webserver/nginx/sbin/nginx -v
    1. nginx 配置文件
    • vi /usr/local/webserver/nginx/conf/nginx.conf
    • 默认配置
    server {
        listen       80;
        server_name  localhost;
    
        location / {
            root   html;
            index  index.html index.htm;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    
    • 配置1 nginx 转发请求到多个tomcat
        #gzip  on;
        
        upstream mytomcats {
            server localhost:8081;
            server localhost:8082;  
        }
            
        server {
            listen       80;
            server_name  localhost;
    
            location / {
                proxy_pass http://mytomcats;
            }
            
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }
    
    1. 检查配置文件 nginx.conf 的正确性命令
    • /usr/local/webserver/nginx/sbin/nginx -t
    1. Nginx 命令
    • 启动
      • /usr/local/webserver/nginx/sbin/nginx
    • 停止
      • /usr/local/webserver/nginx/sbin/nginx -s stop
    • 重新加载
      • /usr/local/webserver/nginx/sbin/nginx -s reload

    相关文章

      网友评论

          本文标题:nginx

          本文链接:https://www.haomeiwen.com/subject/ewlndqtx.html