Nginx配置文件简单说明

原创
2016-08-08 09:27:28 698浏览

配置文件(说明

user nginx;nginx的运行账号(rpm安装时会自动创建这个账号),也可以写成user nginx nginx表示用户和组

worker_processes 10;工作进程数(worker),一般等于cpu内核数或者两倍

worker_rlimit_nofile 100000;文件描述符数量

error_log /var/log/nginx/error.log;#error_log /var/log/nginx/error.log notice;#error_log /var/log/nginx/error.log info;pid /var/run/nginx.pid;events {

worker_connections 1024;每个worker进程允许的连接数

use epoll;网络I/O事件模型,linux推荐用epoll,FreeBSD推荐用kqueue

}http {

include /etc/nginx/mime.types;include用来引用其他的配置文件,即可以按照需求将不同的配置写到不同的文件里面

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"';

定义日志格式,格式名字设为main

access_log /var/log/nginx/access.log main;

access日志文件的路径,采用上面定义的main 格式记录

sendfile on; tcp_nopush on; tcp_nodelay on; server_tokens off;

gzip on;启用压缩

gzip_static on;启用HTTPGzipStatic模块(不在corestandard模块组中,rpm安装带了此模块)

gzip_comp_level 5;压缩级别,1最小最快,9最大最慢

gzip_min_length 1024;压缩的最小长度,小于此长度的不压缩(此长度即header中的Content-Length)

keepalive_timeout 65; limit_zone myzone $binary_remote_addr 10m; # Load config files from the /etc/nginx/conf.d directory include /etc/nginx/conf.d/*.conf; server { limit_conn myzone 10;

listen 80;端口

server_name _;域名

#charset koi8-r; #access_log logs/host.access.log main; location / {

root /usr/share/nginx/html;主目录

index index.html index.htm; }………………

以上就介绍了Nginx配置文件简单说明,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。