#
是注释,不生效的内容
user nobody
nginx启动的时候用什么用户
events
是事件驱动模块
worker_processes
工作进程的个数,一个cpu内核对应一个worker_processes
worker_connections 1024;
每个worker进程默认创建1024个连接
include mime.types;
mime.types记录了请求头返回或者发送的文件是什么类型的,比如文本文档或者html文档,可执行应用程序,flush文件,由服务端向客户端浏览器发送一个头来明确告诉他自己发送的是什么文件。
sendfile on;
数据0拷贝(应用程序不加载磁盘文件),减少数据调度过程
keepalive_timeout 65;
保持连接超时的时间
server
就是一个虚拟主机,可以配置多个虚拟主机,每个主机互相不干扰,可以通过端口号的方式区分每个主机的不同
server_name
可以配置域名或主机名
location
是uri(资源)或者uri的一部分,通过这个找root目录
root
是当前目录匹配上location后从哪个目录找网页
html
是相对nginx程序主目录如/usr/local/nginx/html
error_page 500 502 503 504 /50x.html;
发生服务器端错误时跳转到当前站点的50x.html
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
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 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#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;
}
# 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;
#}
# 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 server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
网友评论