麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 網站 > Nginx > 正文

Linux環境下安裝Nginx及其使用

2024-08-30 12:29:25
字體:
來源:轉載
供稿:網友

一、查看CentOS的版本

cat /etc/redhat-release

二、添加資源庫

在 CentOS 系統上安裝 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

Linux,安裝,Nginx,Linux環境安裝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實現停止、啟動、重啟

systemctl stop nginx.service  systemctl start nginx.servicesystemctl restart nginx.servicesystemctl 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;          }    #靜態文件,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 指令開始}

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


注:相關教程知識閱讀請移步到服務器教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 免费观看黄视频 | 宅男噜噜噜66一区二区 | 欧产日产国产精品v | 国产精品av久久久久久网址 | av在线一区二区三区 | 一级一级一级毛片 | 国产精品视频自拍 | 视频一区二区三区视频 | gril hd| 青热久思思 | 国产一级二级在线播放 | xxxⅹ96日本护士hd | 九九热播视频 | 91精品国产一区二区在线观看 | 久久91亚洲人成电影网站 | 黄色网电影 | 蜜桃传免费看片www 一本色道精品久久一区二区三区 | 91精品国产92久久久久 | 久草资源在线观看 | 日日摸夜夜骑 | 国产免费高清 | av成人免费 | 色视频在线 | 9191久久久久视频 | 国产又粗又爽又深的免费视频 | 在线亚洲播放 | 国内免费视频成人精品 | 国产免费一区二区三区最新不卡 | 操皮视频| 综合精品一区 | 成人免费在线播放 | 黄在线看 | 最新福利在线 | 欧产日产国产精品99 | 毛片在哪里看 | 国产一区国产二区在线观看 | 亚洲情视频| 全黄裸片武则天一级第4季 九色p | 视屏一区 | 久久丝袜脚交足黄网站免费 | 久久久国产精品网站 |