#启动worker进程用户,默认nobody #user nobody; #worker进程数目,默认一个。 可以设置成为 cpu数量或者cpu2倍的数量 worker_processes 1; #日志登记可以是 debug info notice warn error crit ,默认是error #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #配置进程id,在 logs文件夹下有个nginx.pid文件,里面只有一个数值,这个数值就是进程id #pid logs/nginx.pid; #配置工作模式和连接数 events { #配置单个进程的最大连接数,单个最大可设置为65535。总的连接数=连接数*进程数。 worker_connections 1024; } #http配置 http { ###########基本配置#################### #支持哪些多媒体文件,在/usr/local/nginx/conf 下mime.types文件里有一个列表 include mime.types; #默认类型流类型, default_type application/octet-stream; #配置日志格式,向$remote_addr这些是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 logs/access.log main; #开始高效传输模式 sendfile on; #防止网络阻塞 #tcp_nopush on; #长连接超时时间(秒) #keepalive_timeout 0; keepalive_timeout 65; #开启gzip压缩 #gzip on; ############服务配置################### server { #监听端口 listen 80; #可以通过任何ip和域名都可以访问本服务器 server_name localhost; #字符集 #charset koi8-r; #也是日志,如果上面配置了日志,以本日志为主 #access_log logs/host.access.log main; location / { #根目录位置,默认在xxxxxx/nginx/html下的 index.html root html; index index.html index.htm; } #配置404时的页面 #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # #配置50x页面 error_page 500 502 503 504 /50x.html; #精确匹配 location = /50x.html { root html; } #后缀是.php时全部转发到apache服务器 # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ .php$ { # proxy_pass http://127.0.0.1; #} #后缀是.php时全部转发到FastCGI服务器 # 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; # } #} }
指定静态网站路径
location / { root /mnt/g; #指定具路径 index index.html index.htm; }