Nginx as a Web server, its configuration file parameters are as follows:
#user nobody; #默认的运行用户
Worker_processes 1; #工作进程数, the recommended number of CPU cores is the same as the default is 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服务配置, if you have multiple virtual hosts, you can configure the server{} segment for each virtual host
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 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$ {#访问. The configuration section of the PHP page
root/www/html; #PHP网页文档根目录
Fastcgi_pass 127.0.0.1:9000; #PHP-FPM's listening address.
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;
# }
#}
}
This article from "10,000 years too long, seize" blog, please be sure to keep this source http://zengwj1949.blog.51cto.com/10747365/1907201
Nginx configuration file (as Web server)