服务器维护,服务器代维,安全设置,漏洞扫描,入侵检测服务

dirtysea 发表于 2010-9-3 13:35:55

nginx.conf的完整配置说明

<P>#用户和用户组<BR>user www www;</P>
<P>#指令指定处理进程的数量。一般推荐为处理器的个数. 可以适当增加,以避免进程在堵塞在IO等待中。<BR>worker_processes 8;</P>
<P>#错误日志<BR>error_log logs/error.log;</P>
<P>#pid文件位置<BR>pid logs/nginx.pid;</P>
<P>events {<BR>#指定 nginx 处理进程的个数,其与总处理量的关系用公式表达如下:<BR>#MaxClient = worker_processes * worker_connections<BR>#因此这两个数的乘积若大于系统最大可用tcp/ip栈数是没有意义的.<BR>worker_connections 1024;<BR>}</P>
<P>#HTTP 请求设置<BR>http {<BR>#载入mime类型<BR>include mime.types;<BR>#默认类型<BR>default_type application/octet-stream;</P>
<P>#日志的格式<BR>log_format main ‘$remote_addr - $remote_user [$time_local] “$request” ‘<BR>‘$status $body_bytes_sent “$http_referer” ‘<BR>‘”$http_user_agent” “$http_x_forwarded_for”‘;</P>
<P>#访问日志<BR>access_log logs/access.log main;</P>
<P>#sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件,<BR>#对于普通应用,必须设为 on。<BR>#如果用来进行下载等应用磁盘IO重负载应用,可设置为 off,以平衡磁盘与网络IO处理速度,降低系统 uptime。<BR>sendfile on;</P>
<P>tcp_nopush on;</P>
<P>#keepalive_timeout 0;<BR>keepalive_timeout 65;</P>
<P>#gzip on;</P>
<P>#服务器设置<BR>server {<BR>#监听端口<BR>listen 80;</P>
<P>#WEB服务主机名<BR>server_name localhost;</P>
<P>#charset utf-8;</P>
<P>#访问日志<BR>access_log logs/localhost.access.log main;</P>
<P>#请求规则 默认请求<BR>location / {<BR>#WEB根目录<BR>root /home/www/www;<BR>#默认索引文件名<BR>index index.html index.htm index.php;<BR>}</P>
<P>#页面不存在处理<BR>error_page 404 /404.html;</P>
<P>#服务器错误定向<BR>error_page 500 502 503 504 /50x.html;<BR>location = /50x.html {<BR>root /home/www/www;<BR>}<BR>#PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI默认配置.<BR>location ~ \.php$ {<BR>root /home/www/www;<BR>fastcgi_pass 127.0.0.1:9000;<BR>fastcgi_index index.php;<BR>fastcgi_param SCRIPT_FILENAME /home/www/www$fastcgi_script_name;<BR>include fastcgi_params;<BR>}</P>
<P>#禁止访问 .htxxx 文件<BR>location ~ /\.ht {<BR>deny all;<BR>}<BR>}<BR>}</P>
页: [1]
查看完整版本: nginx.conf的完整配置说明