[root@liquan conf]# cat nginx.conf
#user nobody; #指定nginx由哪个用户启动
worker_processes 1; #指定Nginx启动时的worker进程数为1个。
#error_log logs/error.log; #错误日志写入的日志文件地址
#error_log logs/error.log notice; #错误日志notice以上级别的错误消息
#error_log logs/error.log info;
#pid logs/nginx.pid; #记录master进程的pid号
events {
worker_connections 1024; #定义与事件相关的参数。表示每个worker进程可以同时处理
} 的最大连接数,相当于worker进程启动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"';
###
$remote_addr
:客户端的IP地址$remote_user
:远程用户[$time_local]
:访问时间和日期的本地格式"$request"
:HTTP请求的详细信息$status
:HTTP响应状态码$body_bytes_sent
:发送给客户端的字节数"$http_referer"
:HTTP Referer头部字段,表示来源页面的URL"$http_user_agent"
:客户端浏览器的User-Agent信息"$http_x_forwarded_for"
:X-Forwarded-For头部字段,表示客户端真实的IP地址(如果存在代理)
###
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65; #设置客户端与服务器之间空闲连接的超时时间为65秒
#gzip on;
server { #定义虚拟主机,可以定义多个,定义多台虚拟主机时,最好是用
不同域名的方式,而不是不同ip和不同端口
listen 80; #此虚拟主机监听80端口
server_name localhost; #指定虚拟主机的域名或IP地址。
#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 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;
# }
#}
}