nginx配置文件nginx.conf详解
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了nginx配置文件nginx.conf详解,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3257字,纯文字阅读大概需要5分钟。
内容图文
![nginx配置文件nginx.conf详解](/upload/InfoBanner/zyjiaocheng/981/c4e7322de2904af38c1b770e84890e47.jpg)
#运行用户
#user nobody;
#启动进程数,通常设置成和cpu的数量相等
worker_processes 1;
#全局错误日志类型及PID文件
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
#工作模式及连接上限
events {
#单个后台worker process进程的最大并发连接数
worker_connections 1024;
#并发总数是 worker_processes和worker_connections的乘积
}
http {
#设定mime类型,类型由mime.type文件定义
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 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件
sendfile on;
#tcp_nopush on;
#设置连接超时时间
#keepalive_timeout 0;
keepalive_timeout 65;
#开启gzip压缩
gzip_static on;
gzip_proxied expired no-cache no-store private auth;
gzip on;
gzip_types application/javascript text/css text/javascript;
#设定虚拟主机配置
server {
#侦听80端口
listen 80;
#定义使用访问名称
server_name localhost;
#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
#PHP脚本全部转发到fastcgi处理
#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
#禁止访问 .htxxx 文件
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#nginx可以设置的另外一个虚拟主机转发
#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;
# }
#}
}
内容总结
以上是互联网集市为您收集整理的nginx配置文件nginx.conf详解全部内容,希望文章能够帮你解决nginx配置文件nginx.conf详解所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。