zoukankan      html  css  js  c++  java
  • nginx环境搭建

    nginx安装步骤

    安装nginx
    [root@insure opt]# yum install nginx
    启动nginx [root@insure opt]# service nginx start Redirecting to
    /bin/systemctl start nginx.service
    测试nginx是否安装成功 [root@insure opt]# wget http:
    //127.0.0.1 --2019-01-09 10:03:09-- http://127.0.0.1/ Connecting to 127.0.0.1:80... connected. HTTP request sent, awaiting response... 200 OK Length: 3700 (3.6K) [text/html] Saving to: ‘index.html’ 100%[==================================================================================================================================================================>] 3,700 --.-K/s in 0s 2019-01-09 10:03:09 (811 MB/s) - ‘index.html’ saved [3700/3700]

    nginx操作

    查看安装目录
    [root@insure nginx]# whereis nginx nginx:
    /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz /usr/share/man/man3/nginx.3pm.gz [root@insure nginx]# cd /etc/nginx/ [root@insure nginx]# ls conf.d fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utf default.d fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_params.default

    添加前端启动的配置  vi nginx.conf

    server {
            listen       9000 default_server;
            #listen       [::]:80 default_server;
            server_name  _;
            root         /usr/share/nginx/html;
    
            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;
    
    #主要配置这里 location / { root /opt/dev/claimconf/dist; index index.html index.html; try_files $uri $uri/ @router; } location @router { rewrite ^.*$ /index.html last; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }

    server {
    listen 9000 default_server;
    #listen [::]:80 default_server;
    server_name _;
    root /usr/share/nginx/html;

    
    

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    
    

    location / {
    root /opt/dev/claimconf/dist;
    index index.html index.html;
    try_files $uri $uri/ @router;

    
    

    }

    
    

    location @router {
    rewrite ^.*$ /index.html last;
    }

    
    

    error_page 404 /404.html;
    location = /40x.html {
    }

    
    

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
    }

     

    修改完成保存 重启nginx

    service nginx restart 或者nginx -s reload

    由于带宽原因,有两台nginx,最外层一台配置为

    添加配置文件vi /etc/nginx/conf.d/standardprod.conf

    server
    {
        listen 8889;
        server_name standardtest.insuresmart.com.cn;
    
        access_log /var/log/nginx/standardtest_access.log;
        error_log /var/log/nginx/standardtest_error.log;
        root   html;
        index  index.html index.htm index.php;
    
        location / {
            proxy_pass http://standardprod;
    
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_connect_timeout 300s;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
            proxy_buffer_size 64k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
            proxy_ignore_client_abort on;
        }
    
    }

    在配置文件nginx.conf添加

     upstream standardprod
        {
            server   172.16.120.193:9999;
        }

    此端口对应前端布置的nginx设置监听的端口

    yum install -y unzip zip

  • 相关阅读:
    使用svn diff的-r参数的来比较任意两个版本的差异
    mysql client常见error总结
    mysql 中 unix_timestamp,from_unixtime 时间戳函数
    hyperledger explorer 结合 fabric1.4 搭建 区块链浏览器 踩坑记录
    fabric1.4 网络操作
    通过配置连接池大小来提升性能
    docker基本操作及介绍
    InnoDB 引擎中的索引类型
    MySQL互联网业务使用建议
    mysql InnoDB引擎是否支持hash索引
  • 原文地址:https://www.cnblogs.com/mutong1228/p/10242779.html
Copyright © 2011-2022 走看看