Nginx之二:nginx.conf简单配置(参数详解)
2015-04-17 00:07
465 查看
vim /usr/local/nginx/conf/nginx.conf
location = URI 只对当前路径生效(精确匹配指定的路径,不匹配子路径及文件);
location ^~URI 不使用正则表达式;
location ~URI (区分大小写) 及 location ~* (不区分大小写) 模式匹配URI,可以使用正则表达式;
location URI 对当前路径及子路径的所有对象;
在匹配中优先级自上而下;
本文出自 “anka” 博客,请务必保留此出处http://anka0501.blog.51cto.com/10129669/1633694
#user nobody;#程序运行使用账户 worker_processes 1;#启动的进程,通常设置成和cpu的数量相等 #全局错误日志级PID文件 #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { use epoll; #epoll是多路复用IO中的一种方式 worker_connections 1024; #单个后台进行的最大并发连接数 #总并发数为worker_processes*worker_connections的乘积 } http { include mime.types; #定义mime类型,类型有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定义nginx是否调用sendfile函数,对于普通应用,必须开启,如果用来磁盘IO负载应用,可设为off,平衡磁盘与网络IO处理速度 sendfile on; #tcp_nopush on; #连接超时时间 #keepalive_timeout 0; keepalive_timeout 65; #开启gzip压缩 gzip on; gzip_disable "MSIE [1-6]." #设定请求缓冲 client_header_buffer_size 128k; large_client_header_buffers 4 128k; #设置虚拟主机配置 server { listen 80;#监听接口80 server_name www.nginx.com; #设置主机名 #charset koi8-r; #access_log logs/host.access.log main; root /var/www/nginx; 设置网页根目录位置 index index.html index.htm; 定义索引文件的名称 # # 定义错误提示页面 error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} #静态文件,nginx自己处理 location ~ ^/(images|javascript|js|css|flash|media|static)/ { #过期30天,静态文件不怎么更新,过期可以设大一点, #如果频繁更新,则可以设置得小一点。 expires 30d; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI默认配置. location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #禁止访问 .htxxx 文件 location ~ /\.ht { deny all; } } }#Nginx的location配置语法
location = URI 只对当前路径生效(精确匹配指定的路径,不匹配子路径及文件);
location ^~URI 不使用正则表达式;
location ~URI (区分大小写) 及 location ~* (不区分大小写) 模式匹配URI,可以使用正则表达式;
location URI 对当前路径及子路径的所有对象;
在匹配中优先级自上而下;
本文出自 “anka” 博客,请务必保留此出处http://anka0501.blog.51cto.com/10129669/1633694
相关文章推荐
- nginx.conf配置参数详解
- 比较完整的Nginx配置文件nginx.conf常用参数中文详解
- nginx.conf配置文件的参数详解
- 比较完整的Nginx配置文件nginx.conf常用参数中文详解
- Apache httpd.conf配置文件AllowOverride参数详解
- Nginx配置文件nginx.conf中文详解
- nginx配置参数详解
- Nginx配置文件nginx.conf中文详解(总结)
- Nginx配置文件nginx.conf中文详解
- Nginx主配置参数详解,Nginx配置网站
- Nginx配置文件nginx.conf中文详解
- Nginx nginx.conf配置文件详解
- [Nginx]Nginx主配置参数详解,Nginx配置网站
- Nginx配置文件(nginx.conf)配置详解(二)
- Nginx配置文件nginx.conf中文详解(史上最全!!!!)
- Nginx配置文件nginx.conf中文详解
- nginx.conf配置文件的基本详解
- Nginx 配置文件 nginx.conf 详解
- (总结)Nginx配置文件nginx.conf中文详解
- Nginx配置文件nginx.conf中文详解