Nginx配置文件(作为Web服务器)
2017-03-16 13:55
375 查看
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;
# }
#}
}
#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;
# }
#}
}
相关文章推荐
- 使用数据卷容器,配置Nginx Docker作为静态文件服务器
- 文件服务器的nginx web缓存配置
- Nginx高性能web服务器之配置文件(三)
- 高性能Web服务器Nginx的配置与部署研究(12)应用模块之Memcached做文件缓存时压缩引起的问题
- 高性能Web服务器Nginx的配置与部署研究(12)应用模块之Memcached做文件缓存时压缩引起的问题
- nginx作为web 虚拟主机配置文件模板
- Nginx作为web服务器的安装配置
- CentOS 6.4 i386 版本安装 FastDFS、使用Nginx作为文件访问WEB服务器
- 高性能Web服务器Nginx的配置与部署研究(12)应用模块之Memcached做文件缓存时压缩引起的问题
- 高性能Web服务器Nginx的配置与部署研究(4)Nginx常用命令
- tomcat/JSP服务器web.xml文件配置
- 高性能Web服务器Nginx的配置与部署研究
- 高性能Web服务器Nginx的配置与部署研究(6)核心模块之主模块的测试常用指令
- 高性能Web服务器Nginx的配置与部署研究(11)应用模块之Memcached模块的两大应用场景
- 高性能Web服务器Nginx的配置与部署研究(1)Nginx简介及入门示例
- 高性能Web服务器Nginx的配置与部署研究(13)应用模块之Memcached模块+Proxy_Cache双层缓存模式
- 手工更新 Domino Web 服务器配置文件
- 高性能Web服务器Nginx的配置与部署研究(5)Nginx配置符号
- 优化 Web 服务器计算机和特定应用程序的配置文件以符合您的特定需要
- 使用Nginx作为Web服务器的国内网站[原创]