nginx配置详解之main模块
2016-06-15 17:41
302 查看
nginx常用全局配置如下:
以下为各配置参数的详细作用:
user nginx;
#指定nginx用户
worker_processes = 1;
#启动进程数 通常跟cpu数相等 如不清楚可以设置为auto自动监测 如果想知道自己的系统是几核的 可以用下列命令
即为你系统的核数
error_log /var/log/nginx/error.log;
#错误日志配置 注意路径权限
(注:#如果想关闭nginx日志 error_log off 是不行的 使用error_log /dev/null crit; crit为日志级别 关于nginx日志将在在日志模块详细介绍)
worker_rlimit_nofile 2000;
#worker进程的最大打开文件限制数 如果不设置的话,这个值为操作系统的限制 你可以使用ulimit -a命令来查看
输出如下
pid /var/run/nginx.pid;
#pid 文件路径
user nginx; worker_processes = 1; error_log /var/log/nginx/error.log; worker_rlimit_nofile 20000; pid /var/run/nginx.pid;
以下为各配置参数的详细作用:
user nginx;
#指定nginx用户
worker_processes = 1;
#启动进程数 通常跟cpu数相等 如不清楚可以设置为auto自动监测 如果想知道自己的系统是几核的 可以用下列命令
cat /proc/cpuinfo输出如下
processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 45 model name : Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz stepping : 7 microcode : 1808 cpu MHz : 2300.091 cache size : 15360 KB physical id : 0 siblings : 1 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc up rep_good unfair_spinlock pni ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm bogomips : 4600.18 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management:其中的cpu cores
即为你系统的核数
error_log /var/log/nginx/error.log;
#错误日志配置 注意路径权限
(注:#如果想关闭nginx日志 error_log off 是不行的 使用error_log /dev/null crit; crit为日志级别 关于nginx日志将在在日志模块详细介绍)
worker_rlimit_nofile 2000;
#worker进程的最大打开文件限制数 如果不设置的话,这个值为操作系统的限制 你可以使用ulimit -a命令来查看
ulimit -a
输出如下
core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 7800 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 65535 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 10240 cpu time (seconds, -t) unlimited max user processes (-u) 7800 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited其中的open files 即为操作系统的最大限制数 如果nginx出现too many open files 不妨增大这个值
pid /var/run/nginx.pid;
#pid 文件路径
相关文章推荐
- nginx代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- MySQL 优化
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- Nginx 学习笔记(一)
- [游戏资讯]《极品飞车16:亡命狂飙》配置需求公布
- 配置文件神器 typesafe conf 用法简介
- 配置文件神器 typesafe conf 用法简介
- 页面缓存:内存和文件之间的那些事
- 网站502与504错误分析
- 用zabbix监控nginx_status状态
- Google排名优化的几个影响因素
- 路由器备份配置