Nginx作为Web服务器时,其配置文件参数如下:
#user nobody;#默认的运行用户
worker_processes 1;#工作进程数,建议和CPU核心数一致,默认为1
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;#每个进程处理的连接数
}
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;#访问日志配置
sendfile on;#是否支持下载
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {#Web服务配置,如有多个虚拟主机,可以为每个虚拟主机配置server{}段
listen 80;
server_name www.benet.com;#域名(FQDN)
#charset koi8-r;#默认的字符集
#access_log logs/host.access.log main;
location / {#配置根目录
root /www/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 /www/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$ {#访问.php页面的配置段
root /www/html;#PHP网页文档根目录
fastcgi_pass 127.0.0.1:9000;#PHP-FPM的监听地址
fastcgi_index index.php;#PHP首页文件
include fastcgi.conf;
}
# 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;
# }
#}
}本文转自 zengwj1949 51CTO博客,原文链接:http://blog.51cto.com/zengwj1949/1907201