使用Xftp进入/usr/local/nginx/conf
目录下
打开nginx.conf配置文件,将所有带注释的代码全部删除
以下是各行代码的解释
worker_processes 1; # 启动的worker进程数,不是越多越好,太多的话上下文切换过多会消耗性能
events {
worker_connections 1024; #每个worker进程的连接数
}
http {
include mime.types; #include是引入关键字,这里引入了mime.types这个配置文件(同在conf目录下,mime.types是用来定义,请求返回的content-type)
default_type application/octet-stream; #mime.types未定义的,使用默认格式application/octet-stream
sendfile on; #数据零拷贝
keepalive_timeout 65; #长链接超时时间
#一个nginx可以启用多个server(虚拟服务器)
server {
listen 80;#监听端口80
server_name localhost; #当前主机的主机名、域名
#http://{localhost}/{location}
location / {
root html; #根目录指向html目录,相对路径
index index.html index.htm; #默认页,域名/index 指向 index.html index.htm文件
}
error_page 500 502 503 504 /50x.html; # 服务器错误码为500 502 503 504,转到"域名/50x.html"
location = /50x.html {# 指定到html文件夹下找/50x.htm
root html;
}
}
}
这个mine.types文件是用来定义返回的content-type的
可以看到,不同类型的请求文件,对应的content-type不同
这是零拷贝,可以选择打开和关闭
关闭sendfile
开启sendfile