nginx簡單配置

來源:互聯網
上載者:User

標籤:設定檔   網站   動態   

nginx.conf

root   html;  網站目錄

core module :  Main   Events

Standard  HTTP modules :  Core   Access  FastCGI   Gzip  Log  Proxy Rewrite  Upstrem

通過官方查看模組協助 http://nginx.org/en/docs/

.

├── client_body_temp            

├── conf

│   ├── fastcgi.conf    動態配置

│   ├── fastcgi.conf.default

│   ├── fastcgi_params    參數

│   ├── fastcgi_params.default

│   ├── koi-utf

│   ├── koi-win

│   ├── mime.types

│   ├── mime.types.default

│   ├── nginx.conf      靜態設定檔

│   ├── nginx.conf.default

│   ├── scgi_params

│   ├── scgi_params.default

│   ├── uwsgi_params

│   ├── uwsgi_params.default

│   └── win-utf

├── fastcgi_temp

├── html

│   ├── 50x.html   出錯

│   └── index.html

├── logs

│   ├── access.log

│   ├── error.log

│   └── nginx.pid

├── proxy_temp

├── sbin

│   └── nginx

├── scgi_temp

└── uwsgi_temp

 egrep -v "#|^$"   nginx.conf  | cat -n

     1  worker_processes  1;                        和CPU核心數相當     效率

     2  events {

     3      worker_connections  1024;                      worker 可以接受最大多少個連結

     4  }

     5  http {

     6      include       mime.types;

     7      default_type  application/octet-stream;

     8      sendfile        on;

     9      keepalive_timeout  65;

    10      server {

    11          listen       80;

    12          server_name  localhost;                 網域名稱

    13          location / {

    14              root   html;

    15              index  index.html index.htm;

    16          }

    17          error_page   500 502 503 504   /50x.html;         指定錯誤頁面

    18          location = /50x.html {

    19              root   html;

    20          }

    21      }

    22  }

開始配置

server {

        listen       80;

        server_name  www.hequan.com;

            root   html/www;

            index  index.html index.htm;

    }

    server {

        listen       80;

        server_name  blog.hequan.com;

            root   html/blog;

            index  index.html index.htm;

    }

/sbin/nginx   -s reload  

301跳轉

 server {

        listen       80;

        server_name   hequan.com;

          rewrite ^/(.*)  http://www.hequan.com/$1   permanent;

    }

解決惡意IP綁定

 server {

        listen       80;

        location   /  {

                deny all;

        }

    }

日誌切割

cd   /application/nginx/logs  &&  \

/bin/mv www_access.log  www_access_$(date  +%F  -d  -1day).log

/application/nginx/sbin/nginx -s reload

 crontab -e    

00 00 * * *   /bin/sh   /application/nginx/logs/xx.sh   >/dev/null    2&1

日誌相關分析  awstats

200 正常  301 永久跳轉    403  禁止訪問   404 找不到請求的頁面   500  內部伺服器錯誤   502  壞的網關  503  服務當前不可用


本文出自 “何全” 部落格,請務必保留此出處http://hequan.blog.51cto.com/5701886/1767844

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.