listen 80;
server_name www.hongtaofei.com;
location / {
root /home/www/shop/public;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
location ~ \.php$ {
root /home/www/shop/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}自己写的配置文件的话,需要加上标红的代码就可以了
本文介绍了一种具体的Nginx配置方法,详细解释了如何设置listen指令监听端口、定义server_name来指定域名、配置location指令来处理不同路径请求、使用rewrite指令进行URL重写以及如何设置PHP文件通过FastCGI方式传递给后端处理。

被折叠的 条评论
为什么被折叠?



