安裝完nginx后,在安裝目錄下的conf下面找到nginx的配置文件nginx.conf文件。
#Nginx的worker進(jìn)程運(yùn)行的用戶及用戶組
#user nobody;
#Nginx開(kāi)啟的進(jìn)程數(shù)
worker_processes 1;
#定義全局錯(cuò)誤日志定義類型,[debug|info|notice|warn|crit]
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#指定進(jìn)程ID存儲(chǔ)文件位置
#pid logs/nginx.pid;
#----------------------------------------------
#事件配置
events {
#注意:最大客戶數(shù)也由系統(tǒng)的可用socket連接數(shù)限制(~64K),所以設(shè)置不切實(shí)際的高沒(méi)什么好處
worker_connections 1024;
}
#----------------------------------------------
#http參數(shù)
http {
#文件擴(kuò)展名與文件類型映射表,在配置文件同級(jí)目錄下的mime.types文件
include mime.types;
#默認(rèn)文件類型
default_type application/octet-stream;
# 日志相關(guān)定義
#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;
#開(kāi)啟高速傳輸模式
sendfile on;
#tcp_nopush on;
#客戶端連接超時(shí)時(shí)間,單位是秒
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#----------------------虛擬主機(jī)------------------------
server {
#監(jiān)聽(tīng)端口號(hào)
listen 8080;
#訪問(wèn)域名
server_name localhost;
#編碼格式,,若網(wǎng)頁(yè)格式與此不同,將被自動(dòng)轉(zhuǎn)碼
#charset koi8-r;
#虛擬主機(jī)訪問(wèn)日志定義
#access_log logs/host.access.log main;
#對(duì)URL進(jìn)行匹配
location / {
#訪問(wèn)路徑,可相對(duì)也可絕對(duì)路徑
root html;
#首頁(yè)文件。以下按順序匹配
index index.html index.htm;
# proxy_pass http://localhost;
}
#錯(cuò)誤信息返回頁(yè)面
#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;
}
#訪問(wèn)URL以.php結(jié)尾則自動(dòng)轉(zhuǎn)交給127.0.0.1
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
#禁止訪問(wèn).ht頁(yè)面 (需ngx_http_access_module模塊)
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
#HTTPS虛擬主機(jī)定義
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}