daemon off;生产环境中不要使用"daemon"和"master_process"指令,这些选项仅用于开发调试。你可使用daemon off在生产环境中,但对性能提高没有帮助,在生产环境中永远不要使用master_process off。
env MALLOC_OPTIONS;
env PERL5LIB=/data/site/modules;
env OPENSSL_ALLOW_PROXY_CERTS=1;
debug_points stop;在Nginx中有一些调试断点,它们容许Nginx使用调试器,或者停止和创建核心文件。
error_log LOGFILE [debug_core | debug_alloc | debug_mutex | debug_event | debug_http | debug_imap];注意error_log off并不能关闭日志记录功能,它将日志文件写入一个文件名为off的文件中,若是你想关闭错误日志记录功能,应使用如下配置:
error_log /dev/null crit;一样注意0.7.53版本,nginx在读取配置文件指定的错误日志路径前将使用编译的默认日志位置,若是运行nginx的用户对该位置没有写入权限,nginx将输出以下错误:
[alert]: could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
location = /robots.txt {
log_not_found off;
}
include vhosts/*.conf;注意:直到0.6.7版本,这个参数包含的文件路径为你在编译时指定的--prefix=目录,默认是/usr/local/nginx,若是你不想指定这个目录下的文件,请写绝对路径。
lock_file /var/log/lock_file;Nginx使用链接互斥锁进行顺序的accept()系统调用,若是Nginx在i386,amd64,sparc64,与ppc64环境下使用gcc, Intel C++,或SunPro C++进行编译,Nginx使用原子指示使互斥生效,在其余状况下锁文件会被使用。
master_process off;生产环境中不要使用"daemon"和"master_process"指令,这些选项仅用于开发调试。
pid /var/log/nginx.pid;指定pid文件,可使用kill命令来发送相关信号,例如你若是想从新读取配置文件,则可使用:kill -HUP `cat /var/log/nginx.pid`
$ openssl engine -t
(cryptodev) BSD cryptodev engine
[ 可用 ]
(dynamic) Dynamic engine loading support
[ 不可用 ]
timer_resolution 100ms;这个参数容许缩短gettimeofday()系统调用的时间,默认状况下gettimeofday()在下列都调用完成后才会被调用:kevent(), epoll, /dev/poll, select(), poll()。
location / {在Drupal / FastCGI中:
try_files /system/maintenance.html
$uri $uri/index.html $uri.html @mongrel;
}
location @mongrel {
proxy_pass http://mongrel;
}
location / {在这个例子中,这个try_files指令:
try_files $uri $uri/ @drupal;
}
location ~ \.php$ {
try_files $uri @drupal;
fastcgi_pass 127.0.0.1:8888;
fastcgi_param SCRIPT_FILENAME /path/to$fastcgi_script_name;
# other fastcgi_param
}
location @drupal {
fastcgi_pass 127.0.0.1:8888;
fastcgi_param SCRIPT_FILENAME /path/to/index.php;
fastcgi_param QUERY_STRING q=$request_uri;
# other fastcgi_param
}
location / {等同于下列配置:
try_files $uri $uri/ @drupal;
}
location / {这段:
error_page 404 = @drupal;
log_not_found off;
}
location ~ \.php$ {指try_files在将请求提交到FastCGI服务以前检查存在的php文件。
try_files $uri @drupal;
fastcgi_pass 127.0.0.1:8888;
fastcgi_param SCRIPT_FILENAME /path/to$fastcgi_script_name;
# other fastcgi_param
}
location / {
try_files $uri $uri/ @wordpress;
}
location ~ \.php$ {
try_files $uri @wordpress;
fastcgi_pass 127.0.0.1:8888;
fastcgi_param SCRIPT_FILENAME /path/to$fastcgi_script_name;
# other fastcgi_param
}
location @wordpress {
fastcgi_pass 127.0.0.1:8888;
fastcgi_param SCRIPT_FILENAME /path/to/index.php;
# other fastcgi_param
}
user www users;
worker_processes 4;指定每一个进程到一个CPU:
worker_cpu_affinity 0001 0010 0100 1000;
worker_processes 2;指定第一个进程到CPU0/CPU2,指定第二个进程到CPU1/CPU3,对于HTT处理器来讲是一个不错的选择。
worker_cpu_affinity 0101 1010;
worker_processes 5;因为如下几点缘由,Nginx可能须要运行不止一个进程