安装完nginx后,在安装目录下的conf下面找到nginx的配置文件nginx.conf文件。
#Nginx的worker进程运行的用户及用户组
#user nobody;
#Nginx开启的进程数
worker_processes 1;
#定义全局错误日志定义类型,[debug|info|notice|warn|crit]
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#指定进程ID存储文件位置
#pid logs/nginx.pid;
#----------------------------------------------
#事件配置
events {
#注意:最大客户数也由系统的可用socket连接数限制(~64K),所以设置不切实际的高没什么好处
worker_connections 1024;
}
#----------------------------------------------
#http参数
http {
#文件扩展名与文件类型映射表,在配置文件同级目录下的mime.types文件
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;
#tcp_nopush on;
#客户端连接超时时间,单位是秒
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#----------------------虚拟主机------------------------
server {
#监听端口号
listen 8080;
#访问域名
server_name localhost;
#编码格式,,若网页格式与此不同,将被自动转码
#charset koi8-r;
#虚拟主机访问日志定义
#access_log logs/host.access.log main;
#对URL进行匹配
location / {
#访问路径,可相对也可绝对路径
root html;
#首页文件。以下按顺序匹配
index index.html index.htm;
# proxy_pass http://localhost;
}
#错误信息返回页面
#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;
}
#访问URL以.php结尾则自动转交给127.0.0.1
# 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;
#}
#禁止访问.ht页面 (需ngx_http_access_module模块)
# 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虚拟主机定义
# 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;
# }
#}
}
网友评论