nginx笔记

一、配置文件

Nginx.conf

worker_processes 1;  工作进程几个  1

events{

worker_connections 1024;   1个工作进程支持的最大链接数  1024

}

server{    配置虚拟主机

listen 80;

server_name ddd.com;  // 可以写两个 localhost 192.168.2.251

location / {

root html/ddd;  网站根目录 可以是绝对路径也可以是相对路径

Index index.html index.php  默认主页

}

Location ~ .php$ {   每一个虚拟主机php都要单独配置

root          html/ddd;  网站根目录 可以是绝对路径也可以是相对路径,和上面必须一样

fastcgi_pass    127.0.0.1:9000;

fastcgi_index   index.php;

fastcgi_param  SCRIPT_FILENAME  $DOCMENT_ROOT$fastcgi_script_name;

Include        fastcgi_params;

}

}

二、让nginx支持pathinfo

 

 (.*)部分传递到$1 , $1path_info变量赋值

三、nginx 重写

 

If ( ! -e $request_filename ){     如果url地址链接的不是真实文件

rewrite (.*)$ /index.php/$1;    就重写,获取到url转换成index.php的形式

}

原文地址:https://www.cnblogs.com/loveufofbi/p/11915321.html