nginx配置文件详解
一、nginx配置文件详解
#下面这个是工作进程的数量 可以使用auto,但建议使用当前cpu的2倍,2核 的写4.worker_processes 1;#使用哪个用户进行运行.user nobody;#到此为止,之前或是最后一个{}之后的代码称为全局块.类似php的全局变量 下面的events{}是event块. 一般是事件的配置events {#理解并发数就可以了worker_connections 1024;}#http块,主要是http协议相关的设置http {#include是载入的意思,include空格之后的文件一定是存在的. 可以打开 mime.types文件看一下.它是存在的include mime.types;#默认的类型. 还记得header("Content-type:application/octet-stream")吗?default_type application/octet-stream;#一种技术 . 理解加速读取文件sendfile on;#连接超时keepalive_timeout 65;#客户端提交最大client_max_body_size 800M;#注意下面是 http块中的server块..注意,注意,,,server是http中的一个子模块. server下面会提到server {listen 80;server_name localhost;location / {root html;index index.html index.htm;}#错误面error_page 500 502 503 504/50x.html;location =/50x.html {root html;}}#下面这句比较重要,是载入当前目录 下的vhost下的所有的conf文件include vhosts/*.conf;}
二、nginx解析php配置文件详解
#相当于在http模块再添加一个server模块server {#监听绑定80端口listen 80;#下面这个是域名,多个域名用空格隔开server_name www.daj.com daj.com;#本网站的根路径root /绝对路径;#下面是默认首页location / {index index.html index.php;}#下面是针对本站所有.php文件进行处理的配置location ~ \.php{#加载fastcgi 一种处理方式include fastcgi_params;#fastcgi的参数 指定文件路径及参数,否则会有404或是file not find 提示fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;#fastcgi的服务信息 ip:端口fastcgi_pass 127.0.0.1:9000;#fastcgi默认首页fastcgi_index index.php;}}
以上就是这次的全部内容!

浙公网安备 33010602011771号