对 nginx.conf 文件进行配置:
----------
# 在配置文件的顶级main部分,代表worker角色的工作进程的个数
worker_processes 1;
# 错误日志
error_log /usr/local/var/log/nginx/error.log warn;
# 进程文件
pid /usr/local/var/run/nginx.pid;
events {
# 写在events部分。每一个worker进程能并发处理(发起)的最大连接数
worker_connections 256;
}
http {
# 文件扩展名与文件类型映射表
include mime.types;
# 设定默认文件类型
default_type application/octet-stream;
# 为Nginx服务器设置详细的日志格式
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 记录了哪些用户,哪些页面以及用户浏览器、ip和其他的访问信息
# access log 路径
access_log /usr/local/var/log/nginx/access.log main;
# 如果port_in_redirect为off时,那么始终按照默认的80端口;如果该指令打开,那么将会返回当前正在监听的端口。
port_in_redirect off;
# 开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。注意:如果图片显示不正常把这个改成off。
sendfile on;
# 配置信息文件夹,如 Nginx 安装目录不同请自行修改
include /usr/local/etc/nginx/conf.d/*.conf;
}