最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux環(huán)境下安裝Nginx及其使用

 更新時間:2018年03月09日 16:53:06   作者:明天你好向前奔跑  
這篇文章主要介紹了Linux環(huán)境下安裝Nginx及其使用,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

一、查看CentOS的版本

cat /etc/redhat-release

二、添加資源庫

在 CentOS 系統(tǒng)上安裝 Nginx ,得先去添加一個資源庫:

vim /etc/yum.repos.d/nginx.repo
  [nginx]
  name=nginx repo
  baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
  gpgcheck=0
  enabled=1

三、安裝nginx

yum -y install nginx


四、測試nginx配置文件是否正確

nginx -t

打印如下:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

五、CentOS7.0+ nginx實現(xiàn)停止、啟動、重啟

systemctl stop nginx.service  
systemctl start nginx.service
systemctl restart nginx.service
systemctl status nginx.service

開機自啟:

systemctl enable nginx.service

取消開機自啟:

systemctl disable nginx.service

六、nginx.conf配置示例

我的配置:

user nginx;
worker_processes 4;

error_log /var/log/nginx/error.log warn;
pid    /var/run/nginx.pid;


events {
  worker_connections 1024;
}


http {
  include    /etc/nginx/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 /var/log/nginx/access.log main;

  sendfile    on;
  #tcp_nopush   on;

  keepalive_timeout 65;

  #gzip on;

  include /etc/nginx/conf.d/*.conf;

  #設定負載均衡的服務器列表
  upstream pay_server {
    ip_hash;
    server 10.74.248.01:8088 max_fails=2 fail_timeout=2;
    server 10.74.248.02:8088 max_fails=2 fail_timeout=2;
  }

  upstream print_server {
    ip_hash;
    server 10.74.248.03:2001 max_fails=2 fail_timeout=2;
    server 10.74.248.04:2001 max_fails=2 fail_timeout=2;
  }

  upstream accss_door_server {
    ip_hash;
    server 10.74.248.05:2002 max_fails=2 fail_timeout=2;
    server 10.74.248.06:2002 max_fails=2 fail_timeout=2;
  }
  
  server {
    listen 80;
    server_name wab.kupu.ccoop.com.cn;
    location /invengo {
         proxy_pass http://pay_server;
         index index.jsp index.html index.htm;
    }
    location /invengo/epc {
         proxy_pass http://print_server;
         index index.jsp index.html index.htm;
    }
    location /invengo/print {
         proxy_pass http://print_server;
         index index.jsp index.html index.htm;
    }

    location /checkout {
         proxy_pass http://accss_door_server;
         index index.jsp index.html index.htm;
    }
    location /asset {
         proxy_pass http://accss_door_server;
         index index.jsp index.html index.htm;
    }
  }

常用的nginx.conf配置:

user www www;
worker_processes 2;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid    logs/nginx.pid;
events {
  use epoll;
  worker_connections 2048;
}
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壓縮功能設置
  gzip on;
  gzip_min_length 1k;
  gzip_buffers  4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 6;
  gzip_types text/html text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
  gzip_vary on;
 
 # http_proxy 設置
  client_max_body_size  10m;
  client_body_buffer_size  128k;
  proxy_connect_timeout  75;
  proxy_send_timeout  75;
  proxy_read_timeout  75;
  proxy_buffer_size  4k;
  proxy_buffers  4 32k;
  proxy_busy_buffers_size  64k;
  proxy_temp_file_write_size 64k;
  proxy_temp_path  /usr/local/nginx/proxy_temp 1 2;
 # 設定負載均衡后臺服務器列表 
  upstream backend { 
       #ip_hash; 
       server  192.168.10.100:8080 max_fails=2 fail_timeout=30s ; 
       server  192.168.10.101:8080 max_fails=2 fail_timeout=30s ; 
  }
 # 很重要的虛擬主機配置
  server {
    listen    80;
    server_name itoatest.example.com;
    root  /apps/oaapp;
    charset utf-8;
    access_log logs/host.access.log main;
    #對 / 所有做負載均衡+反向代理
    location / {
      root  /apps/oaapp;
      index index.jsp index.html index.htm;
      proxy_pass    http://backend; 
      proxy_redirect off;
      # 后端的Web服務器可以通過X-Forwarded-For獲取用戶真實IP
      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_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
      
    }
    #靜態(tài)文件,nginx自己處理,不去backend請求tomcat
    location ~* /download/ { 
      root /apps/oa/fs; 
      
    }
    location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$  
    {  
      root /apps/oaapp;  
      expires   7d; 
    }
    location /nginx_status {
      stub_status on;
      access_log off;
      allow 192.168.10.0/24;
      deny all;
    }
    location ~ ^/(WEB-INF)/ {  
      deny all;  
    }
    #error_page 404       /404.html;
    # redirect server error pages to the static page /50x.html
    #
    error_page  500 502 503 504 /50x.html;
    location = /50x.html {
      root  html;
    }
  }
 ## 其它虛擬主機,server 指令開始
}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • 詳解linux系統(tǒng)下pid的取值范圍

    詳解linux系統(tǒng)下pid的取值范圍

    這篇文章主要介紹了詳解linux系統(tǒng)下pid的取值范圍的相關資料,需要的朋友可以參考下
    2018-07-07
  • Ubuntu 14.04下安裝和配置redis數(shù)據庫

    Ubuntu 14.04下安裝和配置redis數(shù)據庫

    安裝Redis服務器,會自動地一起安裝Redis命令行客戶端程序。在本機輸入redis-cli命令就可以啟動,客戶端程序訪問Redis服務器。
    2016-04-04
  • Linux 下sftp配置之密鑰方式登錄詳解

    Linux 下sftp配置之密鑰方式登錄詳解

    這篇文章主要介紹了Linux 下sftp配置之密鑰方式登錄詳解的相關資料,為了安全性,需使用sftp,鎖定目錄且不允許sftp用戶登到服務器,需要的朋友可以參考下
    2016-12-12
  • Linux手把手教你實現(xiàn)udp服務器的詳細過程

    Linux手把手教你實現(xiàn)udp服務器的詳細過程

    本文給大家分享Linux實現(xiàn)udp服務器的詳細過程,本文給大家介紹的非常詳細,感興趣的朋友跟隨小編一起看看吧
    2024-04-04
  • htaccess Rewrite中文編碼問題解決方法

    htaccess Rewrite中文編碼問題解決方法

    Seo方面對于中文地址或則文件名,在Google好像比重要大一些,今天正好看到andy的文章.轉下,以后也許會用.
    2008-10-10
  • Vim中文件編碼處理與重新打開亂碼文件詳解

    Vim中文件編碼處理與重新打開亂碼文件詳解

    這篇文章主要給大家介紹了關于Vim中文件編碼處理與重新打開亂碼文件的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧。
    2018-04-04
  • Linux常用命令之chmod修改文件權限777和754

    Linux常用命令之chmod修改文件權限777和754

    這篇文章主要介紹了Linux常用命令之chmod修改文件權限777和754,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-09-09
  • 批處理模式下運行 top 命令的方法

    批處理模式下運行 top 命令的方法

    top 命令 是每個人都在使用的用于 監(jiān)控 Linux 系統(tǒng)性能 的最好的命令。這篇文章給大家介紹批處理模式下運行 top 命令的方法,感興趣的朋友一起看看吧
    2019-10-10
  • linux 分區(qū),格式化,掛載的命令詳細介紹

    linux 分區(qū),格式化,掛載的命令詳細介紹

    這篇文章主要介紹了linux 分區(qū),格式化,掛載的命令詳細介紹的相關資料,這里對命令進行了詳解并附簡單實例說明該如何實現(xiàn),需要的朋友可以參考下
    2016-11-11
  • Linux 文件權限的詳細介紹

    Linux 文件權限的詳細介紹

    這篇文章主要介紹了Linux 文件權限的詳細介紹,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-09-09

最新評論

漳州市| 承德县| 白水县| 来安县| 峡江县| 西安市| 民丰县| 嘉鱼县| 萝北县| 临夏市| 蓬溪县| 兴安盟| 临澧县| 额济纳旗| 灵寿县| 昭通市| 苏州市| 陆良县| 雷州市| 锡林浩特市| 凤阳县| 南江县| 手机| 绩溪县| 周至县| 九龙城区| 正阳县| 比如县| 呼伦贝尔市| 彭州市| 岗巴县| 微博| 仙游县| 项城市| 洛隆县| 大化| 左权县| 页游| 和平县| 分宜县| 疏勒县|