標籤:
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的安裝和設定檔詳細說明