nginx配置详情(持续更新)
来源:互联网 发布:vb中picturebox的文本 编辑:程序博客网 时间:2024/06/16 16:11
user nobody [group]; //设置Nginx使用用户,因安全会创建一新用户,这个时候注意给新用户授权,不然 在下面用户创建日志的时候回权限不够报错,如果测试可直接使用root
worker_processes 8;//worker进程,一般配置为电脑核数,后面预估最大连接:worker_process*worder_connections
error_log logs/error.log debug/notice/info/error/crit;//指定Nginx错误日志的存储目录和日志等级,一般生产设置为error或crit,可以在server和http中配置具体服务的错误日志,分开管理查看,关闭错误日志可使用: error_log /dev/null crit;
pid logs/nginx.pid;//编译的时候指定的进程文件,默认位置在log/
worker_connections 1024;//理论单个worker最大连接数,新装的系统一般默认是1024,即系统最大打开文件数,查看命名:ulimit -n;可以通过如下方式修改:
在/etc/security/limits.conf最后增加*soft nofile 65535 *hard nofile 65535 *soft nproc 65535 *hard nproc 65535
accept_mutex:on(default);//Nginx处理请求互斥锁的开闭,保证连接的处理顺序,在访问量大的情况下,可以修改成off
由于浏览器默认打开两个连接到服务器,Nginx也要发两个到服务器,真正请求连接数为worker_process* worder_connections/4
}
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"';
access_log logs/access.log main buffer=32k //使用上述日志格式并缓冲32k;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream mytest.com{ //配置后端服务器路径及权重
server 127.0.0.1:8080 weight=5;
}
server {
listen 80;
server_name localhost;
charset koi8-r;
access_log logs/host.access.log main;
location ~* .*\.(jpg|jpeg|gif|png|swf|ico)$ { //配置静态文件访问路径,不经过后端服务器处理,实现动静分离
root /usr/local/tomcat/tomcat8/webapps/ROOT/;}
proxy_pass http://mytest.com;
}
#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;
# }
#}
}
- nginx配置详情(持续更新)
- nginx 常用配置详解(持续更新)
- Nginx经验总结(持续更新)
- nginx配置详情
- nginx常用命令(持续更新)
- Nginx配置详情-配置说明-参数优化(一)
- Nginx 日志配置详情解析
- nginx常见错误---持续更新
- Nginx 异常汇总####持续更新
- nginx源码分析(持续更新)
- vim 的配置问题(持续更新)
- php.ini+apache配置(持续更新)
- UEditor配置笔记(持续更新中)
- echarts自定义配置(持续更新)
- IDEA 配置及优化(持续更新)
- gvim配置 持续更新
- Nginx配置详情-配置说明-参数优化-Nginx反向代理、负载均衡(四)
- LNMP= CentOS+Nginx+MySQL+PHP 安装配置及简易建站笔记(持续更新中)
- mbstring 学习
- java基础编程#3
- 010-理性注入|从根本上管理慌张
- RN-第三方-react-native-image-picker,选择图片上传
- java基础十三 权限修饰符
- nginx配置详情(持续更新)
- Lombok 简化java代码注解
- 【redis】centOS安装配置redis
- 内边距 外边距 和元素浮动 清除浮动
- MySQL(1):Win10下MySQL5.7.17免安装版本基本配置
- http://blog.csdn.net/id_no_chinese/article/details/70228121
- 1006. 换个格式输出整数 (15) Python 2 编译
- EditText中的TextWatcher监听
- Java的“跨平台”特性