#user nobody; 定义nginx运行的用户和用户组
worker_processes 1; #nginx进程数,建议设置为等于CPU总核心数
#error_log logs/error.log; 全局错误日志定义类型,[debug|info|notice|warn|error|crit]
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid; 进程文件
#工作模式与连接数上限
events {
worker_connections 1024; #单个进程最大连接数(最大连接数=连接数*进程数)
}
#设定http服务器
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; #开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。注意:如果图片显示不正常把这个改 成off。
#tcp_nopush on; #防止网络阻塞
#keepalive_timeout 0;
keepalive_timeout 65; # 长连接超时时间,单位是秒
#gzip on; gzip模块设置
#虚拟主机的配置
server {
listen 8000; # 监听端口
server_name localhost; # 域名可以有多个,用空格隔开
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html; #站点根目录,即网页文件存放的根目录
index index.html index.htm; #目录内的默认打开文件,如果没有匹配到index.html,则搜索index.htm,依次类推
}
#error_page 404 /404.html; #对错误页面404.html 做了定向配置
# redirect server error pages to the static page /50x.html
#将服务器错误页面重定向到静态页面/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
#将PHP脚本代理到Apache上监听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$ { #将PHP脚本传递给FastCGI服务器,侦听127.0.0.1:9000
# root html;
# fastcgi_pass 127.0.0.1:9000; #抛给本机的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 { #拒绝访问.htaccess文件,如果Apache的文档根目录与nginx文件一致
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#另一个虚拟主机使用基于IP,名称和端口的配置
#第二个站点,用于查看nginx反向代理服务器的运行状态
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server # HTTPS服务器
#
#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;
# }
#}
}
nginx配置文件nginx.conf文件详解
最新推荐文章于 2024-10-24 11:11:23 发布