Nginx的安裝和設定檔詳細說明

來源:互聯網
上載者:User

標籤:

1.nginx的安裝

1.1解壓nginx檔案

1.2 nginx檔案說明

3.啟動nginx

4.驗證是否啟動成功

2 設定檔(說明)

user  nginx;nginx的運行帳號(rpm安裝時會自動建立這個帳號),也可以寫成user nginx nginx表示使用者和組

worker_processes  10;背景工作處理序數(worker),一般等於cpu核心數或者兩倍

worker_rlimit_nofile 100000;檔案描述符數量

 

error_log   /var/log/nginx/error.log;

#error_log  /var/log/nginx/error.log  notice;

#error_log  /var/log/nginx/error.log  info;

 

pid        /var/run/nginx.pid;

 

 

events {

    worker_connections  1024;每個worker進程允許的串連數

    use epoll;網路I/O事件模型,linux推薦用epoll,FreeBSD推薦用kqueue

}

 

 

http {

    include       /etc/nginx/mime.types;include用來引用其他的設定檔,即可以按照需求將不同的配置寫到不同的檔案裡面

    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"‘;

定義日誌格式,格式名字設為main

    access_log  /var/log/nginx/access.log  main;

access記錄檔的路徑,採用上面定義的main 格式記錄

    sendfile        on;

    tcp_nopush      on;

    tcp_nodelay     on;

    server_tokens   off;

    gzip            on;啟用壓縮

    gzip_static     on;啟用HTTPGzipStatic模組(不在core和standard模組組中,但rpm安裝帶了此模組)

    gzip_comp_level 5;壓縮層級,1最小最快,9最大最慢

    gzip_min_length 1024;壓縮的最小長度,小於此長度的不壓縮(此長度即header中的Content-Length)

    keepalive_timeout  65;

    limit_zone   myzone  $binary_remote_addr  10m;

 

    # Load config files from the /etc/nginx/conf.d directory

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

 

    server {

        limit_conn   myzone  10;

        listen       80;連接埠

        server_name  _;網域名稱

 

        #charset koi8-r;

 

        #access_log  logs/host.access.log  main;

 

        location / {

            root   /usr/share/nginx/html;主目錄

            index  index.html index.htm;

        }

………………

 

Nginx的安裝和設定檔詳細說明

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.